source: mainline/uspace/lib/c/include/elf/elf_mod.h@ eec201d

Last change on this file since eec201d was 174156fd, checked in by Jakub Jermar <jakub@…>, 7 years ago

Disambiguate doxygroup generic*

  • Property mode set to 100644
File size: 3.4 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 libc
31 * @{
32 */
33/** @file
34 * @brief ELF loader structures and public functions.
35 */
36
37#ifndef ELF_MOD_H_
38#define ELF_MOD_H_
39
40#include <elf/elf.h>
41#include <stddef.h>
42#include <stdint.h>
43#include <loader/pcb.h>
44
45/**
46 * ELF error return codes
47 */
48#define EE_OK 0 /* No error */
49#define EE_INVALID 1 /* Invalid ELF image */
50#define EE_MEMORY 2 /* Cannot allocate address space */
51#define EE_INCOMPATIBLE 3 /* ELF image is not compatible with current architecture */
52#define EE_UNSUPPORTED 4 /* Non-supported ELF (e.g. dynamic ELFs) */
53#define EE_IRRECOVERABLE 5
54#define EE_IO 6 /* Could not read file. */
55
56typedef enum {
57 /** Leave all segments in RW access mode. */
58 ELDF_RW = 1
59} eld_flags_t;
60
61/** TLS info for a module */
62typedef struct {
63 /** tdata section image */
64 void *tdata;
65 /** Size of tdata section image in bytes */
66 size_t tdata_size;
67 /** Size of tbss section */
68 size_t tbss_size;
69 /** Alignment of TLS initialization image */
70 size_t tls_align;
71} elf_tls_info_t;
72
73/**
74 * Some data extracted from the headers are stored here
75 */
76typedef struct {
77 /** Entry point */
78 entry_point_t entry;
79
80 /** The base address where the file has been loaded.
81 * Points to the ELF file header.
82 */
83 void *base;
84
85 /** ELF interpreter name or NULL if statically-linked */
86 const char *interp;
87
88 /** Pointer to the dynamic section */
89 void *dynamic;
90
91 /** TLS info */
92 elf_tls_info_t tls;
93} elf_finfo_t;
94
95/**
96 * Holds information about an ELF binary being loaded.
97 */
98typedef struct {
99 /** Filedescriptor of the file from which we are loading */
100 int fd;
101
102 /** Difference between run-time addresses and link-time addresses */
103 uintptr_t bias;
104
105 /** Flags passed to the ELF loader. */
106 eld_flags_t flags;
107
108 /** Store extracted info here */
109 elf_finfo_t *info;
110} elf_ld_t;
111
112extern const char *elf_error(unsigned int);
113extern int elf_load_file(int, eld_flags_t, elf_finfo_t *);
114extern int elf_load_file_name(const char *, eld_flags_t, elf_finfo_t *);
115
116#endif
117
118/** @}
119 */
Note: See TracBrowser for help on using the repository browser.