blob: 72efaac97b4b729fc96b105e816b0b9956e283a6 [file] [log] [blame]
Martin Roth9b1b3352016-02-24 12:27:06 -08001#ifndef ELF_H
2#define ELF_H
3
4#define EI_NIDENT 16 /* Size of e_ident array. */
5
6/* Values for e_type. */
7#define ET_NONE 0 /* No file type */
8#define ET_REL 1 /* Relocatable file */
9#define ET_EXEC 2 /* Executable file */
10#define ET_DYN 3 /* Shared object file */
11#define ET_CORE 4 /* Core file */
12
13/* Values for e_machine (architecute). */
14#define EM_NONE 0 /* No machine */
15#define EM_M32 1 /* AT&T WE 32100 */
16#define EM_SPARC 2 /* SUN SPARC */
17#define EM_386 3 /* Intel 80386+ */
18#define EM_68K 4 /* Motorola m68k family */
19#define EM_88K 5 /* Motorola m88k family */
20#define EM_486 6 /* Perhaps disused */
21#define EM_860 7 /* Intel 80860 */
22#define EM_MIPS 8 /* MIPS R3000 big-endian */
23#define EM_S370 9 /* IBM System/370 */
24#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
25
26#define EM_PARISC 15 /* HPPA */
27#define EM_VPP500 17 /* Fujitsu VPP500 */
28#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
29#define EM_960 19 /* Intel 80960 */
30#define EM_PPC 20 /* PowerPC */
31#define EM_PPC64 21 /* PowerPC 64-bit */
32#define EM_S390 22 /* IBM S390 */
33
34#define EM_V800 36 /* NEC V800 series */
35#define EM_FR20 37 /* Fujitsu FR20 */
36#define EM_RH32 38 /* TRW RH-32 */
37#define EM_RCE 39 /* Motorola RCE */
38#define EM_ARM 40 /* ARM */
39#define EM_FAKE_ALPHA 41 /* Digital Alpha */
40#define EM_SH 42 /* Hitachi SH */
41#define EM_SPARCV9 43 /* SPARC v9 64-bit */
42#define EM_TRICORE 44 /* Siemens Tricore */
43#define EM_ARC 45 /* Argonaut RISC Core */
44#define EM_H8_300 46 /* Hitachi H8/300 */
45#define EM_H8_300H 47 /* Hitachi H8/300H */
46#define EM_H8S 48 /* Hitachi H8S */
47#define EM_H8_500 49 /* Hitachi H8/500 */
48#define EM_IA_64 50 /* Intel Merced */
49#define EM_MIPS_X 51 /* Stanford MIPS-X */
50#define EM_COLDFIRE 52 /* Motorola Coldfire */
51#define EM_68HC12 53 /* Motorola M68HC12 */
52#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
53#define EM_PCP 55 /* Siemens PCP */
54#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
55#define EM_NDR1 57 /* Denso NDR1 microprocessor */
56#define EM_STARCORE 58 /* Motorola Start*Core processor */
57#define EM_ME16 59 /* Toyota ME16 processor */
58#define EM_ST100 60 /* STMicroelectronic ST100 processor */
59#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
60#define EM_X86_64 62 /* AMD x86-64 architecture */
61#define EM_PDSP 63 /* Sony DSP Processor */
62
63#define EM_FX66 66 /* Siemens FX66 microcontroller */
64#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
65#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
66#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
67#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
68#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
69#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
70#define EM_SVX 73 /* Silicon Graphics SVx */
71#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
72#define EM_VAX 75 /* Digital VAX */
73#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
74#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
75#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
76#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
77#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
78#define EM_HUANY 81 /* Harvard University machine-independent object files */
79#define EM_PRISM 82 /* SiTera Prism */
80#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
81#define EM_FR30 84 /* Fujitsu FR30 */
82#define EM_D10V 85 /* Mitsubishi D10V */
83#define EM_D30V 86 /* Mitsubishi D30V */
84#define EM_V850 87 /* NEC v850 */
85#define EM_M32R 88 /* Mitsubishi M32R */
86#define EM_MN10300 89 /* Matsushita MN10300 */
87#define EM_MN10200 90 /* Matsushita MN10200 */
88#define EM_PJ 91 /* picoJava */
89#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
90#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
91#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
92#define EM_NUM 95
93
94/* Values for p_type. */
95#define PT_NULL 0 /* Unused entry. */
96#define PT_LOAD 1 /* Loadable segment. */
97#define PT_DYNAMIC 2 /* Dynamic linking information segment. */
98#define PT_INTERP 3 /* Pathname of interpreter. */
99#define PT_NOTE 4 /* Auxiliary information. */
100#define PT_SHLIB 5 /* Reserved (not used). */
101#define PT_PHDR 6 /* Location of program header itself. */
102
103/* Values for p_flags. */
104#define PF_X 0x1 /* Executable. */
105#define PF_W 0x2 /* Writable. */
106#define PF_R 0x4 /* Readable. */
107
108
109#define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */
110
111#define EI_MAG0 0
112#define ELFMAG0 0x7f
113
114#define EI_MAG1 1
115#define ELFMAG1 'E'
116
117#define EI_MAG2 2
118#define ELFMAG2 'L'
119
120#define EI_MAG3 3
121#define ELFMAG3 'F'
122
123#define ELFMAG "\177ELF"
124
125#define EI_CLASS 4 /* File class byte index */
126#define ELFCLASSNONE 0 /* Invalid class */
127#define ELFCLASS32 1 /* 32-bit objects */
128#define ELFCLASS64 2 /* 64-bit objects */
129
130#define EI_DATA 5 /* Data encodeing byte index */
131#define ELFDATANONE 0 /* Invalid data encoding */
132#define ELFDATA2LSB 1 /* 2's complement little endian */
133#define ELFDATA2MSB 2 /* 2's complement big endian */
134
135#define EI_VERSION 6 /* File version byte index */
136 /* Value must be EV_CURRENT */
137
138#define EV_NONE 0 /* Invalid ELF Version */
139#define EV_CURRENT 1 /* Current version */
140
141#define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */
142
143#ifndef ASSEMBLY
144
145#include "stdint.h"
146
147/*
148 * ELF definitions common to all 32-bit architectures.
149 */
150
151typedef uint32_t Elf32_Addr;
152typedef uint16_t Elf32_Half;
153typedef uint32_t Elf32_Off;
154typedef uint16_t Elf32_Section;
155typedef int32_t Elf32_Sword;
156typedef uint32_t Elf32_Word;
157typedef uint32_t Elf32_Size;
158
159typedef uint64_t Elf64_Addr;
160typedef uint16_t Elf64_Half;
161typedef uint64_t Elf64_Off;
162typedef uint16_t Elf64_Section;
163typedef int32_t Elf64_Sword;
164typedef uint32_t Elf64_Word;
165typedef uint64_t Elf64_Size;
166typedef uint64_t Elf64_Xword;
167typedef int64_t Elf64_Sxword;
168
169/*
170 * ELF header.
171 */
172typedef struct {
173 unsigned char e_ident[EI_NIDENT]; /* File identification. */
174 Elf32_Half e_type; /* File type. */
175 Elf32_Half e_machine; /* Machine architecture. */
176 Elf32_Word e_version; /* ELF format version. */
177 Elf32_Addr e_entry; /* Entry point. */
178 Elf32_Off e_phoff; /* Program header file offset. */
179 Elf32_Off e_shoff; /* Section header file offset. */
180 Elf32_Word e_flags; /* Architecture-specific flags. */
181 Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
182 Elf32_Half e_phentsize; /* Size of program header entry. */
183 Elf32_Half e_phnum; /* Number of program header entries. */
184 Elf32_Half e_shentsize; /* Size of section header entry. */
185 Elf32_Half e_shnum; /* Number of section header entries. */
186 Elf32_Half e_shstrndx; /* Section name strings section. */
187} Elf32_Ehdr;
188
189typedef struct {
190 unsigned char e_ident[EI_NIDENT]; /* File identification. */
191 Elf64_Half e_type; /* File type. */
192 Elf64_Half e_machine; /* Machine architecture. */
193 Elf64_Word e_version; /* ELF format version. */
194 Elf64_Addr e_entry; /* Entry point. */
195 Elf64_Off e_phoff; /* Program header file offset. */
196 Elf64_Off e_shoff; /* Section header file offset. */
197 Elf64_Word e_flags; /* Architecture-specific flags. */
198 Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
199 Elf64_Half e_phentsize; /* Size of program header entry. */
200 Elf64_Half e_phnum; /* Number of program header entries. */
201 Elf64_Half e_shentsize; /* Size of section header entry. */
202 Elf64_Half e_shnum; /* Number of section header entries. */
203 Elf64_Half e_shstrndx; /* Section name strings section. */
204} Elf64_Ehdr;
205
206/*
207 * Program header.
208 */
209typedef struct {
210 Elf32_Word p_type; /* Entry type. */
211 Elf32_Off p_offset; /* File offset of contents. */
212 Elf32_Addr p_vaddr; /* Virtual address (not used). */
213 Elf32_Addr p_paddr; /* Physical address. */
214 Elf32_Size p_filesz; /* Size of contents in file. */
215 Elf32_Size p_memsz; /* Size of contents in memory. */
216 Elf32_Word p_flags; /* Access permission flags. */
217 Elf32_Size p_align; /* Alignment in memory and file. */
218} Elf32_Phdr;
219
220typedef struct {
221 Elf64_Word p_type; /* Entry type. */
222 Elf64_Word p_flags; /* Access permission flags. */
223 Elf64_Off p_offset; /* File offset of contents. */
224 Elf64_Addr p_vaddr; /* Virtual address (not used). */
225 Elf64_Addr p_paddr; /* Physical address. */
226 Elf64_Size p_filesz; /* Size of contents in file. */
227 Elf64_Size p_memsz; /* Size of contents in memory. */
228 Elf64_Size p_align; /* Alignment in memory and file. */
229} Elf64_Phdr;
230
231
232/* Dynamic section entry. */
233
234typedef struct
235{
236 Elf32_Sword d_tag; /* Dynamic entry type */
237 union
238 {
239 Elf32_Word d_val; /* Integer value */
240 Elf32_Addr d_ptr; /* Address value */
241 } d_un;
242} Elf32_Dyn;
243
244typedef struct
245{
246 Elf64_Sxword d_tag; /* Dynamic entry type */
247 union
248 {
249 Elf64_Xword d_val; /* Integer value */
250 Elf64_Addr d_ptr; /* Address value */
251 } d_un;
252} Elf64_Dyn;
253
254/* Legal values for d_tag (dynamic entry type). */
255
256#define DT_NULL 0 /* Marks end of dynamic section */
257#define DT_NEEDED 1 /* Name of needed library */
258#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
259#define DT_PLTGOT 3 /* Processor defined value */
260#define DT_HASH 4 /* Address of symbol hash table */
261#define DT_STRTAB 5 /* Address of string table */
262#define DT_SYMTAB 6 /* Address of symbol table */
263#define DT_RELA 7 /* Address of Rela relocs */
264#define DT_RELASZ 8 /* Total size of Rela relocs */
265#define DT_RELAENT 9 /* Size of one Rela reloc */
266#define DT_STRSZ 10 /* Size of string table */
267#define DT_SYMENT 11 /* Size of one symbol table entry */
268#define DT_INIT 12 /* Address of init function */
269#define DT_FINI 13 /* Address of termination function */
270#define DT_SONAME 14 /* Name of shared object */
271#define DT_RPATH 15 /* Library search path (deprecated) */
272#define DT_SYMBOLIC 16 /* Start symbol search here */
273#define DT_REL 17 /* Address of Rel relocs */
274#define DT_RELSZ 18 /* Total size of Rel relocs */
275#define DT_RELENT 19 /* Size of one Rel reloc */
276#define DT_PLTREL 20 /* Type of reloc in PLT */
277#define DT_DEBUG 21 /* For debugging; unspecified */
278#define DT_TEXTREL 22 /* Reloc might modify .text */
279#define DT_JMPREL 23 /* Address of PLT relocs */
280#define DT_BIND_NOW 24 /* Process relocations of object */
281#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
282#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
283#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
284#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
285#define DT_RUNPATH 29 /* Library search path */
286#define DT_FLAGS 30 /* Flags for the object being loaded */
287#define DT_ENCODING 32 /* Start of encoded range */
288#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
289#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
290#define DT_NUM 34 /* Number used */
291#define DT_LOOS 0x6000000d /* Start of OS-specific */
292#define DT_HIOS 0x6ffff000 /* End of OS-specific */
293#define DT_LOPROC 0x70000000 /* Start of processor-specific */
294#define DT_HIPROC 0x7fffffff /* End of processor-specific */
295#define DT_PROCNUM 0x32 /* Most used by any processor */
296
297/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
298 Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
299 approach. */
300#define DT_VALRNGLO 0x6ffffd00
301#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
302#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
303#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
304#define DT_CHECKSUM 0x6ffffdf8
305#define DT_PLTPADSZ 0x6ffffdf9
306#define DT_MOVEENT 0x6ffffdfa
307#define DT_MOVESZ 0x6ffffdfb
308#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
309#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
310 the following DT_* entry. */
311#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
312#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
313#define DT_VALRNGHI 0x6ffffdff
314#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
315#define DT_VALNUM 12
316
317/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
318 Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
319
320 If any adjustment is made to the ELF object after it has been
321 built these entries will need to be adjusted. */
322#define DT_ADDRRNGLO 0x6ffffe00
323#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
324#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
325#define DT_CONFIG 0x6ffffefa /* Configuration information. */
326#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
327#define DT_AUDIT 0x6ffffefc /* Object auditing. */
328#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
329#define DT_MOVETAB 0x6ffffefe /* Move table. */
330#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
331#define DT_ADDRRNGHI 0x6ffffeff
332#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
333#define DT_ADDRNUM 10
334
335/* The versioning entry types. The next are defined as part of the
336 GNU extension. */
337#define DT_VERSYM 0x6ffffff0
338
339#define DT_RELACOUNT 0x6ffffff9
340#define DT_RELCOUNT 0x6ffffffa
341
342/* These were chosen by Sun. */
343#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
344#define DT_VERDEF 0x6ffffffc /* Address of version definition
345 table */
346#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
347#define DT_VERNEED 0x6ffffffe /* Address of table with needed
348 versions */
349#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
350#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
351#define DT_VERSIONTAGNUM 16
352
353/* Sun added these machine-independent extensions in the "processor-specific"
354 range. Be compatible. */
355#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
356#define DT_FILTER 0x7fffffff /* Shared object to get values from */
357#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
358#define DT_EXTRANUM 3
359
360/* Values of `d_un.d_val' in the DT_FLAGS entry. */
361#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */
362#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */
363#define DF_TEXTREL 0x00000004 /* Object contains text relocations */
364#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */
365#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */
366
367/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
368 entry in the dynamic section. */
369#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
370#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
371#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
372#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
373#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
374#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
375#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
376#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */
377#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */
378#define DF_1_TRANS 0x00000200
379#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */
380#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */
381#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */
382#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/
383#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */
384#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */
385#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */
386
387/* Flags for the feature selection in DT_FEATURE_1. */
388#define DTF_1_PARINIT 0x00000001
389#define DTF_1_CONFEXP 0x00000002
390
391/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */
392#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */
393#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not
394 generally available. */
395
396/* Special section indices. */
397
398#define SHN_UNDEF 0 /* Undefined section */
399#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
400#define SHN_LOPROC 0xff00 /* Start of processor-specific */
401#define SHN_HIPROC 0xff1f /* End of processor-specific */
402#define SHN_LOOS 0xff20 /* Start of OS-specific */
403#define SHN_HIOS 0xff3f /* End of OS-specific */
404#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
405#define SHN_COMMON 0xfff2 /* Associated symbol is common */
406#define SHN_XINDEX 0xffff /* Index is in extra table. */
407#define SHN_HIRESERVE 0xffff /* End of reserved indices */
408
409/* Legal values for sh_type (section type). */
410
411#define SHT_NULL 0 /* Section header table entry unused */
412#define SHT_PROGBITS 1 /* Program data */
413#define SHT_SYMTAB 2 /* Symbol table */
414#define SHT_STRTAB 3 /* String table */
415#define SHT_RELA 4 /* Relocation entries with addends */
416#define SHT_HASH 5 /* Symbol hash table */
417#define SHT_DYNAMIC 6 /* Dynamic linking information */
418#define SHT_NOTE 7 /* Notes */
419#define SHT_NOBITS 8 /* Program space with no data (bss) */
420#define SHT_REL 9 /* Relocation entries, no addends */
421#define SHT_SHLIB 10 /* Reserved */
422#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
423#define SHT_INIT_ARRAY 14 /* Array of constructors */
424#define SHT_FINI_ARRAY 15 /* Array of destructors */
425#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
426#define SHT_GROUP 17 /* Section group */
427#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
428#define SHT_NUM 19 /* Number of defined types. */
429#define SHT_LOOS 0x60000000 /* Start OS-specific */
430#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
431#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */
432#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */
433#define SHT_SUNW_move 0x6ffffffa
434#define SHT_SUNW_COMDAT 0x6ffffffb
435#define SHT_SUNW_syminfo 0x6ffffffc
436#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
437#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
438#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
439#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
440#define SHT_HIOS 0x6fffffff /* End OS-specific type */
441#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
442#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
443#define SHT_LOUSER 0x80000000 /* Start of application-specific */
444#define SHT_HIUSER 0x8fffffff /* End of application-specific */
445
446/* Legal values for sh_flags (section flags). */
447
448#define SHF_WRITE (1 << 0) /* Writable */
449#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
450#define SHF_EXECINSTR (1 << 2) /* Executable */
451#define SHF_MERGE (1 << 4) /* Might be merged */
452#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
453#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
454#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
455#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
456 required */
457#define SHF_GROUP (1 << 9) /* Section is member of a group. */
458#define SHF_TLS (1 << 10) /* Section hold thread-local data. */
459#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
460#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
461
462/* Section group handling. */
463#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */
464
465/* Symbol table entry. */
466
467typedef struct
468{
469 Elf32_Word st_name; /* Symbol name (string tbl index) */
470 Elf32_Addr st_value; /* Symbol value */
471 Elf32_Word st_size; /* Symbol size */
472 unsigned char st_info; /* Symbol type and binding */
473 unsigned char st_other; /* Symbol visibility */
474 Elf32_Section st_shndx; /* Section index */
475} Elf32_Sym;
476
477typedef struct
478{
479 Elf64_Word st_name; /* Symbol name (string tbl index) */
480 unsigned char st_info; /* Symbol type and binding */
481 unsigned char st_other; /* Symbol visibility */
482 Elf64_Section st_shndx; /* Section index */
483 Elf64_Addr st_value; /* Symbol value */
484 Elf64_Xword st_size; /* Symbol size */
485} Elf64_Sym;
486
487/* Relocation table entry without addend (in section of type SHT_REL). */
488
489typedef struct
490{
491 Elf32_Addr r_offset; /* Address */
492 Elf32_Word r_info; /* Relocation type and symbol index */
493} Elf32_Rel;
494
495/* I have seen two different definitions of the Elf64_Rel and
496 Elf64_Rela structures, so we'll leave them out until Novell (or
497 whoever) gets their act together. */
498/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */
499
500typedef struct
501{
502 Elf64_Addr r_offset; /* Address */
503 Elf64_Xword r_info; /* Relocation type and symbol index */
504} Elf64_Rel;
505
506/* Relocation table entry with addend (in section of type SHT_RELA). */
507
508typedef struct
509{
510 Elf32_Addr r_offset; /* Address */
511 Elf32_Word r_info; /* Relocation type and symbol index */
512 Elf32_Sword r_addend; /* Addend */
513} Elf32_Rela;
514
515typedef struct
516{
517 Elf64_Addr r_offset; /* Address */
518 Elf64_Xword r_info; /* Relocation type and symbol index */
519 Elf64_Sxword r_addend; /* Addend */
520} Elf64_Rela;
521
522/* How to extract and insert information held in the r_info field. */
523
524#define ELF32_R_SYM(val) ((val) >> 8)
525#define ELF32_R_TYPE(val) ((val) & 0xff)
526#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
527
528#define ELF64_R_SYM(i) ((i) >> 32)
529#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
530#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type))
531
532
533/* Intel 80386 specific definitions. */
534
535/* i386 relocs. */
536
537#define R_386_NONE 0 /* No reloc */
538#define R_386_32 1 /* Direct 32 bit */
539#define R_386_PC32 2 /* PC relative 32 bit */
540#define R_386_GOT32 3 /* 32 bit GOT entry */
541#define R_386_PLT32 4 /* 32 bit PLT address */
542#define R_386_COPY 5 /* Copy symbol at runtime */
543#define R_386_GLOB_DAT 6 /* Create GOT entry */
544#define R_386_JMP_SLOT 7 /* Create PLT entry */
545#define R_386_RELATIVE 8 /* Adjust by program base */
546#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
547#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
548#define R_386_32PLT 11
549#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
550#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
551 block offset */
552#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
553 offset */
554#define R_386_TLS_LE 17 /* Offset relative to static TLS
555 block */
556#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
557 general dynamic thread local data */
558#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
559 local dynamic thread local data
560 in LE code */
561#define R_386_16 20
562#define R_386_PC16 21
563#define R_386_8 22
564#define R_386_PC8 23
565#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
566 thread local data */
567#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
568#define R_386_TLS_GD_CALL 26 /* Relocation for call to
569 __tls_get_addr() */
570#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
571#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
572 thread local data in LE code */
573#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
574#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
575 __tls_get_addr() in LDM code */
576#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
577#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
578#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
579 block offset */
580#define R_386_TLS_LE_32 34 /* Negated offset relative to static
581 TLS block */
582#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
583#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
584#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
585/* Keep this the last entry. */
586#define R_386_NUM 38
587
588#endif /* ASSEMBLY */
589
590#endif /* ELF_H */