source: mainline/uspace/lib/c/include/elf/elf_load.h@ db80a2e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since db80a2e was c0699467, checked in by Martin Decky <martin@…>, 14 years ago

do not provide general access to kernel headers from uspace, only allow specific headers to be accessed or shared
externalize headers which serve as kernel/uspace API/ABI into a special tree

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2006 Sergey Bondari
3 * Copyright (c) 2008 Jiri Svoboda
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup generic
31 * @{
32 */
33/** @file
34 * @brief ELF loader structures and public functions.
35 */
36
37#ifndef ELF_LOAD_H_
38#define ELF_LOAD_H_
39
40#include <elf/elf.h>
41#include <sys/types.h>
42#include <loader/pcb.h>
43
44/**
45 * ELF error return codes
46 */
47#define EE_OK 0 /* No error */
48#define EE_INVALID 1 /* Invalid ELF image */
49#define EE_MEMORY 2 /* Cannot allocate address space */
50#define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */
51#define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */
52#define EE_LOADER 5 /* The image is actually a program loader. */
53#define EE_IRRECOVERABLE 6
54
55typedef enum {
56 /** Leave all segments in RW access mode. */
57 ELDF_RW = 1
58} eld_flags_t;
59
60/**
61 * Some data extracted from the headers are stored here
62 */
63typedef struct {
64 /** Entry point */
65 entry_point_t entry;
66
67 /** ELF interpreter name or NULL if statically-linked */
68 const char *interp;
69
70 /** Pointer to the dynamic section */
71 void *dynamic;
72} elf_info_t;
73
74/**
75 * Holds information about an ELF binary being loaded.
76 */
77typedef struct {
78 /** Filedescriptor of the file from which we are loading */
79 int fd;
80
81 /** Difference between run-time addresses and link-time addresses */
82 uintptr_t bias;
83
84 /** Flags passed to the ELF loader. */
85 eld_flags_t flags;
86
87 /** A copy of the ELF file header */
88 elf_header_t *header;
89
90 /** Store extracted info here */
91 elf_info_t *info;
92} elf_ld_t;
93
94extern const char *elf_error(unsigned int);
95extern int elf_load_file(const char *, size_t, eld_flags_t, elf_info_t *);
96extern void elf_create_pcb(elf_info_t *, pcb_t *);
97
98#endif
99
100/** @}
101 */
Note: See TracBrowser for help on using the repository browser.