direct-io.hg

view tools/libxc/xc_elf.h @ 12765:2dd4569e0640

[LIBXC] Add an error reporting API to the libxc library.

- An 'xc_error' struct is used to pass around error
details. Currently contains two members 'code' an enumeration of
error types, and 'message' a free text description of the specific
problem.

- The xc_get_last_error() method returns a const pointer to the
internal instance of this struct manged by libxc. By returning a
const pointer we can add extra members to the end of the struct at
any time without worrying about ABI of callers. This will let us
provide more fine-grained info if needed in the future.

- The xc_error instance is statically defined inside libxc and marked
__thread. This ensures that errors are recorded per-thread, and
that when dealing with errors we never need to call malloc - all
storage needed is statically allocated.

- The xc_clear_last_error() method resets any currently recorded
error details

- The xc_error_code_to_desc() method converts the integer error code
into a generic user facing messsage. eg "Invalid kernel". Together
with the 'message' field from xc_error, this provides the user
visible feedback. eg "Invalid kernel: Non PAE-kernel on PAE host."

- A callback can be registered with xc_set_error_handler to receive
notification whenever an error is recorded, rather than querying
for error details after the fact with xc_get_last_error

- If built with -DDEBUG set, a default error handler will be
registered which calls fprintf(stderr), thus maintaining current
behaviour of logging errors to stderr during developer builds.

- The python binding for libxc is updated to use xc_get_last_error
to pull out error details whenever appropriate, instead of
returning info based on 'errno'

- The xc_set_error method is private to libxc internals, and is used
for setting error details

- The ERROR and PERROR macros have been updated to call xc_set_error
automatically specifying XC_INTERNAL_ERROR as the error code. This
gives a generic error report for all current failure points

- Some uses of the ERROR macro have been replaced with explicit
calls to xc_set_error to enable finer grained error reporting. In
particular the code dealing with invalid kernel types uses this
to report about PAE/architecture/wordsize mismatches

The patch has been tested by calling xm create against a varietry of
config files defining invalid kernels of various kinds. It has also
been tested with libvirt talking to xend. In both cases the error
messages were propagated all the way back up the stack.

There is only one place where I need to do further work. The suspend
& restore APIs in Xend invoke external helper programs rather than
calling libxc directly. This means that error details are essentially
lost. Since there is already code in XenD which scans STDERR from
these programs I will investigate adapting this to extract actual
error messages from these helpers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author kfraser@localhost.localdomain
date Thu Dec 07 11:36:26 2006 +0000 (2006-12-07)
parents 1650e07c9e52
children db3d03dfe92f
line source
1 /*
2 * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
27 typedef uint8_t Elf_Byte;
29 typedef uint32_t Elf32_Addr; /* Unsigned program address */
30 typedef uint32_t Elf32_Off; /* Unsigned file offset */
31 typedef int32_t Elf32_Sword; /* Signed large integer */
32 typedef uint32_t Elf32_Word; /* Unsigned large integer */
33 typedef uint16_t Elf32_Half; /* Unsigned medium integer */
35 typedef uint64_t Elf64_Addr;
36 typedef uint64_t Elf64_Off;
37 typedef int32_t Elf64_Shalf;
39 typedef int32_t Elf64_Sword;
40 typedef uint32_t Elf64_Word;
42 typedef int64_t Elf64_Sxword;
43 typedef uint64_t Elf64_Xword;
45 typedef uint32_t Elf64_Half;
46 typedef uint16_t Elf64_Quarter;
48 /*
49 * e_ident[] identification indexes
50 * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
51 */
52 #define EI_MAG0 0 /* file ID */
53 #define EI_MAG1 1 /* file ID */
54 #define EI_MAG2 2 /* file ID */
55 #define EI_MAG3 3 /* file ID */
56 #define EI_CLASS 4 /* file class */
57 #define EI_DATA 5 /* data encoding */
58 #define EI_VERSION 6 /* ELF header version */
59 #define EI_OSABI 7 /* OS/ABI ID */
60 #define EI_ABIVERSION 8 /* ABI version */
61 #define EI_PAD 9 /* start of pad bytes */
62 #define EI_NIDENT 16 /* Size of e_ident[] */
64 /* e_ident[] magic number */
65 #define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
66 #define ELFMAG1 'E' /* e_ident[EI_MAG1] */
67 #define ELFMAG2 'L' /* e_ident[EI_MAG2] */
68 #define ELFMAG3 'F' /* e_ident[EI_MAG3] */
69 #define ELFMAG "\177ELF" /* magic */
70 #define SELFMAG 4 /* size of magic */
72 /* e_ident[] file class */
73 #define ELFCLASSNONE 0 /* invalid */
74 #define ELFCLASS32 1 /* 32-bit objs */
75 #define ELFCLASS64 2 /* 64-bit objs */
76 #define ELFCLASSNUM 3 /* number of classes */
78 /* e_ident[] data encoding */
79 #define ELFDATANONE 0 /* invalid */
80 #define ELFDATA2LSB 1 /* Little-Endian */
81 #define ELFDATA2MSB 2 /* Big-Endian */
82 #define ELFDATANUM 3 /* number of data encode defines */
84 /* e_ident[] Operating System/ABI */
85 #define ELFOSABI_SYSV 0 /* UNIX System V ABI */
86 #define ELFOSABI_HPUX 1 /* HP-UX operating system */
87 #define ELFOSABI_NETBSD 2 /* NetBSD */
88 #define ELFOSABI_LINUX 3 /* GNU/Linux */
89 #define ELFOSABI_HURD 4 /* GNU/Hurd */
90 #define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
91 #define ELFOSABI_SOLARIS 6 /* Solaris */
92 #define ELFOSABI_MONTEREY 7 /* Monterey */
93 #define ELFOSABI_IRIX 8 /* IRIX */
94 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
95 #define ELFOSABI_TRU64 10 /* TRU64 UNIX */
96 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
97 #define ELFOSABI_OPENBSD 12 /* OpenBSD */
98 #define ELFOSABI_ARM 97 /* ARM */
99 #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
101 /* e_ident */
102 #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
103 (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
104 (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
105 (ehdr).e_ident[EI_MAG3] == ELFMAG3)
107 /* ELF Header */
108 typedef struct elfhdr {
109 unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
110 Elf32_Half e_type; /* object file type */
111 Elf32_Half e_machine; /* machine */
112 Elf32_Word e_version; /* object file version */
113 Elf32_Addr e_entry; /* virtual entry point */
114 Elf32_Off e_phoff; /* program header table offset */
115 Elf32_Off e_shoff; /* section header table offset */
116 Elf32_Word e_flags; /* processor-specific flags */
117 Elf32_Half e_ehsize; /* ELF header size */
118 Elf32_Half e_phentsize; /* program header entry size */
119 Elf32_Half e_phnum; /* number of program header entries */
120 Elf32_Half e_shentsize; /* section header entry size */
121 Elf32_Half e_shnum; /* number of section header entries */
122 Elf32_Half e_shstrndx; /* section header table's "section
123 header string table" entry offset */
124 } Elf32_Ehdr;
126 typedef struct {
127 unsigned char e_ident[EI_NIDENT]; /* Id bytes */
128 Elf64_Quarter e_type; /* file type */
129 Elf64_Quarter e_machine; /* machine type */
130 Elf64_Half e_version; /* version number */
131 Elf64_Addr e_entry; /* entry point */
132 Elf64_Off e_phoff; /* Program hdr offset */
133 Elf64_Off e_shoff; /* Section hdr offset */
134 Elf64_Half e_flags; /* Processor flags */
135 Elf64_Quarter e_ehsize; /* sizeof ehdr */
136 Elf64_Quarter e_phentsize; /* Program header entry size */
137 Elf64_Quarter e_phnum; /* Number of program headers */
138 Elf64_Quarter e_shentsize; /* Section header entry size */
139 Elf64_Quarter e_shnum; /* Number of section headers */
140 Elf64_Quarter e_shstrndx; /* String table index */
141 } Elf64_Ehdr;
143 /* e_type */
144 #define ET_NONE 0 /* No file type */
145 #define ET_REL 1 /* relocatable file */
146 #define ET_EXEC 2 /* executable file */
147 #define ET_DYN 3 /* shared object file */
148 #define ET_CORE 4 /* core file */
149 #define ET_NUM 5 /* number of types */
150 #define ET_LOPROC 0xff00 /* reserved range for processor */
151 #define ET_HIPROC 0xffff /* specific e_type */
153 /* e_machine */
154 #define EM_NONE 0 /* No Machine */
155 #define EM_M32 1 /* AT&T WE 32100 */
156 #define EM_SPARC 2 /* SPARC */
157 #define EM_386 3 /* Intel 80386 */
158 #define EM_68K 4 /* Motorola 68000 */
159 #define EM_88K 5 /* Motorola 88000 */
160 #define EM_486 6 /* Intel 80486 - unused? */
161 #define EM_860 7 /* Intel 80860 */
162 #define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
163 /*
164 * Don't know if EM_MIPS_RS4_BE,
165 * EM_SPARC64, EM_PARISC,
166 * or EM_PPC are ABI compliant
167 */
168 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
169 #define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */
170 #define EM_PARISC 15 /* HPPA */
171 #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
172 #define EM_PPC 20 /* PowerPC */
173 #define EM_PPC64 21 /* PowerPC 64-bit */
174 #define EM_ARM 40 /* Advanced RISC Machines ARM */
175 #define EM_ALPHA 41 /* DEC ALPHA */
176 #define EM_SPARCV9 43 /* SPARC version 9 */
177 #define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */
178 #define EM_IA_64 50 /* Intel Merced */
179 #define EM_X86_64 62 /* AMD x86-64 architecture */
180 #define EM_VAX 75 /* DEC VAX */
182 /* Version */
183 #define EV_NONE 0 /* Invalid */
184 #define EV_CURRENT 1 /* Current */
185 #define EV_NUM 2 /* number of versions */
187 /* Section Header */
188 typedef struct {
189 Elf32_Word sh_name; /* name - index into section header
190 string table section */
191 Elf32_Word sh_type; /* type */
192 Elf32_Word sh_flags; /* flags */
193 Elf32_Addr sh_addr; /* address */
194 Elf32_Off sh_offset; /* file offset */
195 Elf32_Word sh_size; /* section size */
196 Elf32_Word sh_link; /* section header table index link */
197 Elf32_Word sh_info; /* extra information */
198 Elf32_Word sh_addralign; /* address alignment */
199 Elf32_Word sh_entsize; /* section entry size */
200 } Elf32_Shdr;
202 typedef struct {
203 Elf64_Half sh_name; /* section name */
204 Elf64_Half sh_type; /* section type */
205 Elf64_Xword sh_flags; /* section flags */
206 Elf64_Addr sh_addr; /* virtual address */
207 Elf64_Off sh_offset; /* file offset */
208 Elf64_Xword sh_size; /* section size */
209 Elf64_Half sh_link; /* link to another */
210 Elf64_Half sh_info; /* misc info */
211 Elf64_Xword sh_addralign; /* memory alignment */
212 Elf64_Xword sh_entsize; /* table entry size */
213 } Elf64_Shdr;
215 /* Special Section Indexes */
216 #define SHN_UNDEF 0 /* undefined */
217 #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
218 #define SHN_LOPROC 0xff00 /* reserved range for processor */
219 #define SHN_HIPROC 0xff1f /* specific section indexes */
220 #define SHN_ABS 0xfff1 /* absolute value */
221 #define SHN_COMMON 0xfff2 /* common symbol */
222 #define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
224 /* sh_type */
225 #define SHT_NULL 0 /* inactive */
226 #define SHT_PROGBITS 1 /* program defined information */
227 #define SHT_SYMTAB 2 /* symbol table section */
228 #define SHT_STRTAB 3 /* string table section */
229 #define SHT_RELA 4 /* relocation section with addends*/
230 #define SHT_HASH 5 /* symbol hash table section */
231 #define SHT_DYNAMIC 6 /* dynamic section */
232 #define SHT_NOTE 7 /* note section */
233 #define SHT_NOBITS 8 /* no space section */
234 #define SHT_REL 9 /* relation section without addends */
235 #define SHT_SHLIB 10 /* reserved - purpose unknown */
236 #define SHT_DYNSYM 11 /* dynamic symbol table section */
237 #define SHT_NUM 12 /* number of section types */
238 #define SHT_LOPROC 0x70000000 /* reserved range for processor */
239 #define SHT_HIPROC 0x7fffffff /* specific section header types */
240 #define SHT_LOUSER 0x80000000 /* reserved range for application */
241 #define SHT_HIUSER 0xffffffff /* specific indexes */
243 /* Section names */
244 #define ELF_BSS ".bss" /* uninitialized data */
245 #define ELF_DATA ".data" /* initialized data */
246 #define ELF_DEBUG ".debug" /* debug */
247 #define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
248 #define ELF_DYNSTR ".dynstr" /* dynamic string table */
249 #define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
250 #define ELF_FINI ".fini" /* termination code */
251 #define ELF_GOT ".got" /* global offset table */
252 #define ELF_HASH ".hash" /* symbol hash table */
253 #define ELF_INIT ".init" /* initialization code */
254 #define ELF_REL_DATA ".rel.data" /* relocation data */
255 #define ELF_REL_FINI ".rel.fini" /* relocation termination code */
256 #define ELF_REL_INIT ".rel.init" /* relocation initialization code */
257 #define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
258 #define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
259 #define ELF_REL_TEXT ".rel.text" /* relocation code */
260 #define ELF_RODATA ".rodata" /* read-only data */
261 #define ELF_SHSTRTAB ".shstrtab" /* section header string table */
262 #define ELF_STRTAB ".strtab" /* string table */
263 #define ELF_SYMTAB ".symtab" /* symbol table */
264 #define ELF_TEXT ".text" /* code */
267 /* Section Attribute Flags - sh_flags */
268 #define SHF_WRITE 0x1 /* Writable */
269 #define SHF_ALLOC 0x2 /* occupies memory */
270 #define SHF_EXECINSTR 0x4 /* executable */
271 #define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
272 /* specific section attributes */
274 /* Symbol Table Entry */
275 typedef struct elf32_sym {
276 Elf32_Word st_name; /* name - index into string table */
277 Elf32_Addr st_value; /* symbol value */
278 Elf32_Word st_size; /* symbol size */
279 unsigned char st_info; /* type and binding */
280 unsigned char st_other; /* 0 - no defined meaning */
281 Elf32_Half st_shndx; /* section header index */
282 } Elf32_Sym;
284 typedef struct {
285 Elf64_Half st_name; /* Symbol name index in str table */
286 Elf_Byte st_info; /* type / binding attrs */
287 Elf_Byte st_other; /* unused */
288 Elf64_Quarter st_shndx; /* section index of symbol */
289 Elf64_Xword st_value; /* value of symbol */
290 Elf64_Xword st_size; /* size of symbol */
291 } Elf64_Sym;
293 /* Symbol table index */
294 #define STN_UNDEF 0 /* undefined */
296 /* Extract symbol info - st_info */
297 #define ELF32_ST_BIND(x) ((x) >> 4)
298 #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
299 #define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
301 #define ELF64_ST_BIND(x) ((x) >> 4)
302 #define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf)
303 #define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
305 /* Symbol Binding - ELF32_ST_BIND - st_info */
306 #define STB_LOCAL 0 /* Local symbol */
307 #define STB_GLOBAL 1 /* Global symbol */
308 #define STB_WEAK 2 /* like global - lower precedence */
309 #define STB_NUM 3 /* number of symbol bindings */
310 #define STB_LOPROC 13 /* reserved range for processor */
311 #define STB_HIPROC 15 /* specific symbol bindings */
313 /* Symbol type - ELF32_ST_TYPE - st_info */
314 #define STT_NOTYPE 0 /* not specified */
315 #define STT_OBJECT 1 /* data object */
316 #define STT_FUNC 2 /* function */
317 #define STT_SECTION 3 /* section */
318 #define STT_FILE 4 /* file */
319 #define STT_NUM 5 /* number of symbol types */
320 #define STT_LOPROC 13 /* reserved range for processor */
321 #define STT_HIPROC 15 /* specific symbol types */
323 /* Relocation entry with implicit addend */
324 typedef struct {
325 Elf32_Addr r_offset; /* offset of relocation */
326 Elf32_Word r_info; /* symbol table index and type */
327 } Elf32_Rel;
329 /* Relocation entry with explicit addend */
330 typedef struct {
331 Elf32_Addr r_offset; /* offset of relocation */
332 Elf32_Word r_info; /* symbol table index and type */
333 Elf32_Sword r_addend;
334 } Elf32_Rela;
336 /* Extract relocation info - r_info */
337 #define ELF32_R_SYM(i) ((i) >> 8)
338 #define ELF32_R_TYPE(i) ((unsigned char) (i))
339 #define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
341 typedef struct {
342 Elf64_Xword r_offset; /* where to do it */
343 Elf64_Xword r_info; /* index & type of relocation */
344 } Elf64_Rel;
346 typedef struct {
347 Elf64_Xword r_offset; /* where to do it */
348 Elf64_Xword r_info; /* index & type of relocation */
349 Elf64_Sxword r_addend; /* adjustment value */
350 } Elf64_Rela;
352 #define ELF64_R_SYM(info) ((info) >> 32)
353 #define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF)
354 #define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t))
356 /* Program Header */
357 typedef struct {
358 Elf32_Word p_type; /* segment type */
359 Elf32_Off p_offset; /* segment offset */
360 Elf32_Addr p_vaddr; /* virtual address of segment */
361 Elf32_Addr p_paddr; /* physical address - ignored? */
362 Elf32_Word p_filesz; /* number of bytes in file for seg. */
363 Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
364 Elf32_Word p_flags; /* flags */
365 Elf32_Word p_align; /* memory alignment */
366 } Elf32_Phdr;
368 typedef struct {
369 Elf64_Half p_type; /* entry type */
370 Elf64_Half p_flags; /* flags */
371 Elf64_Off p_offset; /* offset */
372 Elf64_Addr p_vaddr; /* virtual address */
373 Elf64_Addr p_paddr; /* physical address */
374 Elf64_Xword p_filesz; /* file size */
375 Elf64_Xword p_memsz; /* memory size */
376 Elf64_Xword p_align; /* memory & file alignment */
377 } Elf64_Phdr;
379 /* Segment types - p_type */
380 #define PT_NULL 0 /* unused */
381 #define PT_LOAD 1 /* loadable segment */
382 #define PT_DYNAMIC 2 /* dynamic linking section */
383 #define PT_INTERP 3 /* the RTLD */
384 #define PT_NOTE 4 /* auxiliary information */
385 #define PT_SHLIB 5 /* reserved - purpose undefined */
386 #define PT_PHDR 6 /* program header */
387 #define PT_NUM 7 /* Number of segment types */
388 #define PT_LOPROC 0x70000000 /* reserved range for processor */
389 #define PT_HIPROC 0x7fffffff /* specific segment types */
391 /* Segment flags - p_flags */
392 #define PF_X 0x1 /* Executable */
393 #define PF_W 0x2 /* Writable */
394 #define PF_R 0x4 /* Readable */
395 #define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
396 /* specific segment flags */
398 /* Dynamic structure */
399 typedef struct {
400 Elf32_Sword d_tag; /* controls meaning of d_val */
401 union {
402 Elf32_Word d_val; /* Multiple meanings - see d_tag */
403 Elf32_Addr d_ptr; /* program virtual address */
404 } d_un;
405 } Elf32_Dyn;
407 typedef struct {
408 Elf64_Xword d_tag; /* controls meaning of d_val */
409 union {
410 Elf64_Addr d_ptr;
411 Elf64_Xword d_val;
412 } d_un;
413 } Elf64_Dyn;
415 /* Dynamic Array Tags - d_tag */
416 #define DT_NULL 0 /* marks end of _DYNAMIC array */
417 #define DT_NEEDED 1 /* string table offset of needed lib */
418 #define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
419 #define DT_PLTGOT 3 /* address PLT/GOT */
420 #define DT_HASH 4 /* address of symbol hash table */
421 #define DT_STRTAB 5 /* address of string table */
422 #define DT_SYMTAB 6 /* address of symbol table */
423 #define DT_RELA 7 /* address of relocation table */
424 #define DT_RELASZ 8 /* size of relocation table */
425 #define DT_RELAENT 9 /* size of relocation entry */
426 #define DT_STRSZ 10 /* size of string table */
427 #define DT_SYMENT 11 /* size of symbol table entry */
428 #define DT_INIT 12 /* address of initialization func. */
429 #define DT_FINI 13 /* address of termination function */
430 #define DT_SONAME 14 /* string table offset of shared obj */
431 #define DT_RPATH 15 /* string table offset of library
432 search path */
433 #define DT_SYMBOLIC 16 /* start sym search in shared obj. */
434 #define DT_REL 17 /* address of rel. tbl. w addends */
435 #define DT_RELSZ 18 /* size of DT_REL relocation table */
436 #define DT_RELENT 19 /* size of DT_REL relocation entry */
437 #define DT_PLTREL 20 /* PLT referenced relocation entry */
438 #define DT_DEBUG 21 /* bugger */
439 #define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
440 #define DT_JMPREL 23 /* add. of PLT's relocation entries */
441 #define DT_BIND_NOW 24 /* Bind now regardless of env setting */
442 #define DT_NUM 25 /* Number used. */
443 #define DT_LOPROC 0x70000000 /* reserved range for processor */
444 #define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
446 /* Standard ELF hashing function */
447 unsigned int elf_hash(const unsigned char *name);
449 /*
450 * Note Definitions
451 */
452 typedef struct {
453 Elf32_Word namesz;
454 Elf32_Word descsz;
455 Elf32_Word type;
456 } Elf32_Note;
458 typedef struct {
459 Elf64_Half namesz;
460 Elf64_Half descsz;
461 Elf64_Half type;
462 } Elf64_Note;
465 #if defined(ELFSIZE)
466 #define CONCAT(x,y) __CONCAT(x,y)
467 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
468 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
469 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
470 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
471 #endif
473 #if defined(ELFSIZE) && (ELFSIZE == 32)
474 #define Elf_Ehdr Elf32_Ehdr
475 #define Elf_Phdr Elf32_Phdr
476 #define Elf_Shdr Elf32_Shdr
477 #define Elf_Sym Elf32_Sym
478 #define Elf_Rel Elf32_Rel
479 #define Elf_RelA Elf32_Rela
480 #define Elf_Dyn Elf32_Dyn
481 #define Elf_Word Elf32_Word
482 #define Elf_Sword Elf32_Sword
483 #define Elf_Addr Elf32_Addr
484 #define Elf_Off Elf32_Off
485 #define Elf_Nhdr Elf32_Nhdr
486 #define Elf_Note Elf32_Note
488 #define ELF_R_SYM ELF32_R_SYM
489 #define ELF_R_TYPE ELF32_R_TYPE
490 #define ELF_R_INFO ELF32_R_INFO
491 #define ELFCLASS ELFCLASS32
493 #define ELF_ST_BIND ELF32_ST_BIND
494 #define ELF_ST_TYPE ELF32_ST_TYPE
495 #define ELF_ST_INFO ELF32_ST_INFO
497 #define AuxInfo Aux32Info
498 #elif defined(ELFSIZE) && (ELFSIZE == 64)
499 #define Elf_Ehdr Elf64_Ehdr
500 #define Elf_Phdr Elf64_Phdr
501 #define Elf_Shdr Elf64_Shdr
502 #define Elf_Sym Elf64_Sym
503 #define Elf_Rel Elf64_Rel
504 #define Elf_RelA Elf64_Rela
505 #define Elf_Dyn Elf64_Dyn
506 #define Elf_Word Elf64_Word
507 #define Elf_Sword Elf64_Sword
508 #define Elf_Addr Elf64_Addr
509 #define Elf_Off Elf64_Off
510 #define Elf_Nhdr Elf64_Nhdr
511 #define Elf_Note Elf64_Note
513 #define ELF_R_SYM ELF64_R_SYM
514 #define ELF_R_TYPE ELF64_R_TYPE
515 #define ELF_R_INFO ELF64_R_INFO
516 #define ELFCLASS ELFCLASS64
518 #define ELF_ST_BIND ELF64_ST_BIND
519 #define ELF_ST_TYPE ELF64_ST_TYPE
520 #define ELF_ST_INFO ELF64_ST_INFO
522 #define AuxInfo Aux64Info
523 #endif