]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
1 | /* This file defines standard ELF types, structures, and macros. |
2 | Copyright (C) 1995 Free Software Foundation, Inc. | |
3 | Contributed by Ian Lance Taylor (ian@cygnus.com). | |
4 | ||
5 | This file is part of the GNU C Library. | |
6 | ||
7 | The GNU C Library is free software; you can redistribute it and/or | |
8 | modify it under the terms of the GNU Library General Public License as | |
9 | published by the Free Software Foundation; either version 2 of the | |
10 | License, or (at your option) any later version. | |
11 | ||
12 | The GNU C Library is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Library General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Library General Public | |
18 | License along with the GNU C Library; see the file COPYING.LIB. If | |
19 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
20 | Cambridge, MA 02139, USA. */ | |
21 | ||
22 | #ifndef _ELF_H | |
23 | #define _ELF_H 1 | |
24 | ||
25 | ||
26 | /* Standard ELF types. | |
27 | ||
28 | Using __attribute__ mode ensures that gcc will choose the right for | |
29 | these types. */ | |
30 | ||
31 | typedef unsigned int Elf32_Addr __attribute__ ((mode (SI))); | |
32 | typedef unsigned int Elf32_Half __attribute__ ((mode (HI))); | |
33 | typedef unsigned int Elf32_Off __attribute__ ((mode (SI))); | |
34 | typedef int Elf32_Sword __attribute__ ((mode (SI))); | |
35 | typedef unsigned int Elf32_Word __attribute__ ((mode (SI))); | |
36 | ||
37 | /* The ELF file header. This appears at the start of every ELF file. */ | |
38 | ||
39 | #define EI_NIDENT (16) | |
40 | ||
41 | typedef struct | |
42 | { | |
43 | unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ | |
44 | Elf32_Half e_type; /* Object file type */ | |
45 | Elf32_Half e_machine; /* Architecture */ | |
46 | Elf32_Word e_version; /* Object file version */ | |
47 | Elf32_Addr e_entry; /* Entry point virtual address */ | |
48 | Elf32_Off e_phoff; /* Program header table file offset */ | |
49 | Elf32_Off e_shoff; /* Section header table file offset */ | |
50 | Elf32_Word e_flags; /* Processor-specific flags */ | |
51 | Elf32_Half e_ehsize; /* ELF header size in bytes */ | |
52 | Elf32_Half e_phentsize; /* Program header table entry size */ | |
53 | Elf32_Half e_phnum; /* Program header table entry count */ | |
54 | Elf32_Half e_shentsize; /* Section header table entry size */ | |
55 | Elf32_Half e_shnum; /* Section header table entry count */ | |
56 | Elf32_Half e_shstrndx; /* Section header string table index */ | |
57 | } Elf32_Ehdr; | |
58 | ||
59 | /* Fields in the e_ident array. The EI_* macros are indices into the | |
60 | array. The macros under each EI_* macro are the values the byte | |
61 | may have. */ | |
62 | ||
63 | #define EI_MAG0 0 /* File identification byte 0 index */ | |
64 | #define ELFMAG0 0x7f /* Magic number byte 0 */ | |
65 | ||
66 | #define EI_MAG1 1 /* File identification byte 1 index */ | |
67 | #define ELFMAG1 'E' /* Magic number byte 1 */ | |
68 | ||
69 | #define EI_MAG2 2 /* File identification byte 2 index */ | |
70 | #define ELFMAG2 'L' /* Magic number byte 2 */ | |
71 | ||
72 | #define EI_MAG3 3 /* File identification byte 3 index */ | |
73 | #define ELFMAG3 'F' /* Magic number byte 3 */ | |
74 | ||
b7976c00 RM |
75 | /* Conglomeration of the identification bytes, for easy testing as a word. */ |
76 | #define ELFMAG "\x7fELF" | |
77 | #define SELFMAG 4 | |
78 | ||
28f540f4 RM |
79 | #define EI_CLASS 4 /* File class byte index */ |
80 | #define ELFCLASSNONE 0 /* Invalid class */ | |
81 | #define ELFCLASS32 1 /* 32-bit objects */ | |
82 | #define ELFCLASS64 2 /* 64-bit objects */ | |
83 | ||
84 | #define EI_DATA 5 /* Data encoding byte index */ | |
85 | #define ELFDATANONE 0 /* Invalid data encoding */ | |
86 | #define ELFDATA2LSB 1 /* 2's complement, little endian */ | |
87 | #define ELFDATA2MSB 2 /* 2's complement, big endian */ | |
88 | ||
89 | #define EI_VERSION 6 /* File version byte index */ | |
90 | /* Value must be EV_CURRENT */ | |
91 | ||
92 | #define EI_PAD 7 /* Byte index of padding bytes */ | |
93 | ||
94 | /* Legal values for e_type (object file type). */ | |
95 | ||
96 | #define ET_NONE 0 /* No file type */ | |
97 | #define ET_REL 1 /* Relocatable file */ | |
98 | #define ET_EXEC 2 /* Executable file */ | |
99 | #define ET_DYN 3 /* Shared object file */ | |
100 | #define ET_CORE 4 /* Core file */ | |
101 | #define ET_LOPROC 0xff00 /* Processor-specific */ | |
102 | #define ET_HIPROC 0xffff /* Processor-specific */ | |
103 | ||
104 | /* Legal values for e_machine (architecture). */ | |
105 | ||
106 | #define EM_NONE 0 /* No machine */ | |
107 | #define EM_M32 1 /* AT&T WE 32100 */ | |
108 | #define EM_SPARC 2 /* SUN SPARC */ | |
109 | #define EM_386 3 /* Intel 80386 */ | |
110 | #define EM_68K 4 /* Motorola m68k family */ | |
111 | #define EM_88K 5 /* Motorola m88k family */ | |
112 | #define EM_486 6 /* Intel 80486 */ | |
113 | #define EM_860 7 /* Intel 80860 */ | |
114 | #define EM_MIPS 8 /* MIPS R3000 big-endian */ | |
115 | #define EM_S370 9 /* Amdhal */ | |
116 | #define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */ | |
117 | ||
118 | #define EM_SPARC64 11 /* SPARC v9 (not official) 64-bit */ | |
119 | ||
120 | #define EM_PARISC 15 /* HPPA */ | |
121 | ||
122 | /* If it is necessary to assign new unofficial EM_* values, please | |
123 | pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the | |
124 | chances of collision with official or non-GNU unofficial values. */ | |
125 | ||
126 | /* Legal values for e_version (version). */ | |
127 | ||
128 | #define EV_NONE 0 /* Invalid ELF version */ | |
129 | #define EV_CURRENT 1 /* Current version */ | |
130 | ||
131 | /* Section header. */ | |
132 | ||
133 | typedef struct | |
134 | { | |
135 | Elf32_Word sh_name; /* Section name (string tbl index) */ | |
136 | Elf32_Word sh_type; /* Section type */ | |
137 | Elf32_Word sh_flags; /* Section flags */ | |
138 | Elf32_Addr sh_addr; /* Section virtual addr at execution */ | |
139 | Elf32_Off sh_offset; /* Section file offset */ | |
140 | Elf32_Word sh_size; /* Section size in bytes */ | |
141 | Elf32_Word sh_link; /* Link to another section */ | |
142 | Elf32_Word sh_info; /* Additional section information */ | |
143 | Elf32_Word sh_addralign; /* Section alignment */ | |
144 | Elf32_Word sh_entsize; /* Entry size if section holds table */ | |
145 | } Elf32_Shdr; | |
146 | ||
147 | /* Special section indices. */ | |
148 | ||
149 | #define SHN_UNDEF 0 /* Undefined section */ | |
150 | #define SHN_LORESERVE 0xff00 /* Start of reserved indices */ | |
151 | #define SHN_LOPROC 0xff00 /* Start of processor-specific */ | |
152 | #define SHN_HIPROC 0xff1f /* End of processor-specific */ | |
153 | #define SHN_ABS 0xfff1 /* Associated symbol is absolute */ | |
154 | #define SHN_COMMON 0xfff2 /* Associated symbol is common */ | |
155 | #define SHN_HIRESERVE 0xffff /* End of reserved indices */ | |
156 | ||
157 | /* Legal values for sh_type (section type). */ | |
158 | ||
159 | #define SHT_NULL 0 /* Section header table entry unused */ | |
160 | #define SHT_PROGBITS 1 /* Program data */ | |
161 | #define SHT_SYMTAB 2 /* Symbol table */ | |
162 | #define SHT_STRTAB 3 /* String table */ | |
163 | #define SHT_RELA 4 /* Relocation entries with addends */ | |
164 | #define SHT_HASH 5 /* Symbol hash table */ | |
165 | #define SHT_DYNAMIC 6 /* Dynamic linking information */ | |
166 | #define SHT_NOTE 7 /* Notes */ | |
167 | #define SHT_NOBITS 8 /* Program space with no data (bss) */ | |
168 | #define SHT_REL 9 /* Relocation entries, no addends */ | |
169 | #define SHT_SHLIB 10 /* Reserved */ | |
170 | #define SHT_DYNSYM 11 /* Dynamic linker symbol table */ | |
171 | #define SHT_LOPROC 0x70000000 /* Start of processor-specific */ | |
172 | #define SHT_HIPROC 0x7fffffff /* End of processor-specific */ | |
173 | #define SHT_LOUSER 0x80000000 /* Start of application-specific */ | |
174 | #define SHT_HIUSER 0x8fffffff /* End of application-specific */ | |
175 | ||
176 | /* Legal values for sh_flags (section flags). */ | |
177 | ||
178 | #define SHF_WRITE (1 << 0) /* Writable */ | |
179 | #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ | |
180 | #define SHF_EXECINSTR (1 << 2) /* Executable */ | |
181 | #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ | |
182 | ||
183 | /* Symbol table entry. */ | |
184 | ||
185 | typedef struct | |
186 | { | |
187 | Elf32_Word st_name; /* Symbol name (string tbl index) */ | |
188 | Elf32_Addr st_value; /* Symbol value */ | |
189 | Elf32_Word st_size; /* Symbol size */ | |
190 | unsigned char st_info; /* Symbol type and binding */ | |
191 | unsigned char st_other; /* No defined meaning, 0 */ | |
192 | Elf32_Half st_shndx; /* Section index */ | |
193 | } Elf32_Sym; | |
194 | ||
b1f11361 | 195 | /* Special section index. */ |
28f540f4 | 196 | |
b1f11361 | 197 | #define SHN_UNDEF 0 /* No section, undefined symbol. */ |
28f540f4 RM |
198 | |
199 | /* How to extract and insert information held in the st_info field. */ | |
200 | ||
201 | #define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) | |
202 | #define ELF32_ST_TYPE(val) ((val) & 0xf) | |
203 | #define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) | |
204 | ||
205 | /* Legal values for ST_BIND subfield of st_info (symbol binding). */ | |
206 | ||
207 | #define STB_LOCAL 0 /* Local symbol */ | |
208 | #define STB_GLOBAL 1 /* Global symbol */ | |
209 | #define STB_WEAK 2 /* Weak symbol */ | |
210 | #define STB_LOPROC 13 /* Start of processor-specific */ | |
211 | #define STB_HIPROC 15 /* End of processor-specific */ | |
212 | ||
213 | /* Legal values for ST_TYPE subfield of st_info (symbol type). */ | |
214 | ||
215 | #define STT_NOTYPE 0 /* Symbol type is unspecified */ | |
216 | #define STT_OBJECT 1 /* Symbol is a data object */ | |
217 | #define STT_FUNC 2 /* Symbol is a code object */ | |
218 | #define STT_SECTION 3 /* Symbol associated with a section */ | |
219 | #define STT_FILE 4 /* Symbol's name is file name */ | |
220 | #define STT_LOPROC 13 /* Start of processor-specific */ | |
221 | #define STT_HIPROC 15 /* End of processor-specific */ | |
222 | ||
b1f11361 RM |
223 | |
224 | /* Symbol table indices are found in the hash buckets and chain table | |
225 | of a symbol hash table section. This special index value indicates | |
226 | the end of a chain, meaning no further symbols are found in that bucket. */ | |
227 | ||
228 | #define STN_UNDEF 0 /* End of a chain. */ | |
229 | ||
230 | ||
28f540f4 RM |
231 | /* Relocation table entry without addend (in section of type SHT_REL). */ |
232 | ||
233 | typedef struct | |
234 | { | |
235 | Elf32_Addr r_offset; /* Address */ | |
236 | Elf32_Word r_info; /* Relocation type and symbol index */ | |
237 | } Elf32_Rel; | |
238 | ||
239 | /* Relocation table entry with addend (in section of type SHT_RELA). */ | |
240 | ||
241 | typedef struct | |
242 | { | |
243 | Elf32_Addr r_offset; /* Address */ | |
244 | Elf32_Word r_info; /* Relocation type and symbol index */ | |
245 | Elf32_Sword r_addend; /* Addend */ | |
246 | } Elf32_Rela; | |
247 | ||
248 | /* How to extract and insert information held in the r_info field. */ | |
249 | ||
250 | #define ELF32_R_SYM(val) ((val) >> 8) | |
251 | #define ELF32_R_TYPE(val) ((val) & 0xff) | |
252 | #define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) | |
253 | ||
254 | /* Program segment header. */ | |
255 | ||
256 | typedef struct { | |
257 | Elf32_Word p_type; /* Segment type */ | |
258 | Elf32_Off p_offset; /* Segment file offset */ | |
259 | Elf32_Addr p_vaddr; /* Segment virtual address */ | |
260 | Elf32_Addr p_paddr; /* Segment physical address */ | |
261 | Elf32_Word p_filesz; /* Segment size in file */ | |
262 | Elf32_Word p_memsz; /* Segment size in memory */ | |
263 | Elf32_Word p_flags; /* Segment flags */ | |
264 | Elf32_Word p_align; /* Segment alignment */ | |
265 | } Elf32_Phdr; | |
266 | ||
267 | /* Legal values for p_type (segment type). */ | |
268 | ||
269 | #define PT_NULL 0 /* Program header table entry unused */ | |
270 | #define PT_LOAD 1 /* Loadable program segment */ | |
271 | #define PT_DYNAMIC 2 /* Dynamic linking information */ | |
272 | #define PT_INTERP 3 /* Program interpreter */ | |
273 | #define PT_NOTE 4 /* Auxiliary information */ | |
274 | #define PT_SHLIB 5 /* Reserved */ | |
275 | #define PT_PHDR 6 /* Entry for header table itself */ | |
276 | #define PT_LOPROC 0x70000000 /* Start of processor-specific */ | |
277 | #define PT_HIPROC 0x7fffffff /* End of processor-specific */ | |
278 | ||
279 | /* Legal values for p_flags (segment flags). */ | |
280 | ||
281 | #define PF_X (1 << 0) /* Segment is executable */ | |
282 | #define PF_W (1 << 1) /* Segment is writable */ | |
283 | #define PF_R (1 << 2) /* Segment is readable */ | |
284 | #define PF_MASKPROC 0xf0000000 /* Processor-specific */ | |
285 | ||
286 | /* Dynamic section entry. */ | |
287 | ||
288 | typedef struct | |
289 | { | |
290 | Elf32_Sword d_tag; /* Dynamic entry type */ | |
291 | union | |
292 | { | |
293 | Elf32_Word d_val; /* Integer value */ | |
294 | Elf32_Addr d_ptr; /* Address value */ | |
295 | } d_un; | |
296 | } Elf32_Dyn; | |
297 | ||
298 | /* Legal values for d_tag (dynamic entry type). */ | |
299 | ||
300 | #define DT_NULL 0 /* Marks end of dynamic section */ | |
301 | #define DT_NEEDED 1 /* Name of needed library */ | |
302 | #define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ | |
303 | #define DT_PLTGOT 3 /* Processor defined value */ | |
304 | #define DT_HASH 4 /* Address of symbol hash table */ | |
305 | #define DT_STRTAB 5 /* Address of string table */ | |
306 | #define DT_SYMTAB 6 /* Address of symbol table */ | |
307 | #define DT_RELA 7 /* Address of Rela relocs */ | |
308 | #define DT_RELASZ 8 /* Total size of Rela relocs */ | |
309 | #define DT_RELAENT 9 /* Size of one Rela reloc */ | |
310 | #define DT_STRSZ 10 /* Size of string table */ | |
311 | #define DT_SYMENT 11 /* Size of one symbol table entry */ | |
312 | #define DT_INIT 12 /* Address of init function */ | |
313 | #define DT_FINI 13 /* Address of termination function */ | |
314 | #define DT_SONAME 14 /* Name of shared object */ | |
315 | #define DT_RPATH 15 /* Library search path */ | |
316 | #define DT_SYMBOLIC 16 /* Start symbol search here */ | |
317 | #define DT_REL 17 /* Address of Rel relocs */ | |
318 | #define DT_RELSZ 18 /* Total size of Rel relocs */ | |
319 | #define DT_RELENT 19 /* Size of one Rel reloc */ | |
320 | #define DT_PLTREL 20 /* Type of reloc in PLT */ | |
321 | #define DT_DEBUG 21 /* For debugging; unspecified */ | |
322 | #define DT_TEXTREL 22 /* Reloc might modify .text */ | |
323 | #define DT_JMPREL 23 /* Address of PLT relocs */ | |
d8cc5f0c | 324 | #define DT_NUM 24 /* Number used. */ |
28f540f4 RM |
325 | #define DT_LOPROC 0x70000000 /* Start of processor-specific */ |
326 | #define DT_HIPROC 0x7fffffff /* End of processor-specific */ | |
327 | ||
328 | /* Standard 64 bit ELF types. */ | |
329 | ||
330 | typedef unsigned int Elf64_Addr __attribute__ ((mode (DI))); | |
331 | typedef unsigned int Elf64_Half __attribute__ ((mode (HI))); | |
332 | typedef unsigned int Elf64_Off __attribute__ ((mode (DI))); | |
333 | typedef int Elf64_Sword __attribute__ ((mode (SI))); | |
334 | typedef int Elf64_Sxword __attribute__ ((mode (DI))); | |
335 | typedef unsigned int Elf64_Word __attribute__ ((mode (SI))); | |
336 | typedef unsigned int Elf64_Xword __attribute__ ((mode (DI))); | |
337 | typedef unsigned int Elf64_Byte __attribute__ ((mode (QI))); | |
338 | typedef unsigned int Elf64_Section __attribute__ ((mode (HI))); | |
339 | ||
340 | /* 64 bit ELF file header. */ | |
341 | ||
342 | typedef struct | |
343 | { | |
344 | unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ | |
345 | Elf64_Half e_type; /* Object file type */ | |
346 | Elf64_Half e_machine; /* Architecture */ | |
347 | Elf64_Word e_version; /* Object file version */ | |
348 | Elf64_Addr e_entry; /* Entry point virtual address */ | |
349 | Elf64_Off e_phoff; /* Program header table file offset */ | |
350 | Elf64_Off e_shoff; /* Section header table file offset */ | |
351 | Elf64_Word e_flags; /* Processor-specific flags */ | |
352 | Elf64_Half e_ehsize; /* ELF header size in bytes */ | |
353 | Elf64_Half e_phentsize; /* Program header table entry size */ | |
354 | Elf64_Half e_phnum; /* Program header table entry count */ | |
355 | Elf64_Half e_shentsize; /* Section header table entry size */ | |
356 | Elf64_Half e_shnum; /* Section header table entry count */ | |
357 | Elf64_Half e_shstrndx; /* Section header string table index */ | |
358 | } Elf64_Ehdr; | |
359 | ||
360 | /* 64 bit section header. */ | |
361 | ||
362 | typedef struct | |
363 | { | |
364 | Elf64_Word sh_name; /* Section name (string tbl index) */ | |
365 | Elf64_Word sh_type; /* Section type */ | |
366 | Elf64_Xword sh_flags; /* Section flags */ | |
367 | Elf64_Addr sh_addr; /* Section virtual addr at execution */ | |
368 | Elf64_Off sh_offset; /* Section file offset */ | |
369 | Elf64_Xword sh_size; /* Section size in bytes */ | |
370 | Elf64_Word sh_link; /* Link to another section */ | |
371 | Elf64_Word sh_info; /* Additional section information */ | |
372 | Elf64_Xword sh_addralign; /* Section alignment */ | |
373 | Elf64_Xword sh_entsize; /* Entry size if section holds table */ | |
374 | } Elf64_Shdr; | |
375 | ||
376 | /* 64 bit symbol table entry. */ | |
377 | ||
378 | typedef struct | |
379 | { | |
380 | Elf64_Word st_name; /* Symbol name (string tbl index) */ | |
381 | Elf64_Byte st_info; /* Symbol type and binding */ | |
382 | Elf64_Byte st_other; /* No defined meaning, 0 */ | |
383 | Elf64_Section st_shndx; /* Section index */ | |
384 | Elf64_Addr st_value; /* Symbol value */ | |
385 | Elf64_Xword st_size; /* Symbol size */ | |
386 | } Elf64_Sym; | |
387 | ||
388 | /* The 64 bit st_info field is the same as the 32 bit one. */ | |
389 | ||
390 | #define ELF64_ST_BIND(val) (((unsigned char) (val)) >> 4) | |
391 | #define ELF64_ST_TYPE(val) ((val) & 0xf) | |
392 | #define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) | |
393 | ||
394 | /* I have seen two different definitions of the Elf64_Rel and | |
395 | Elf64_Rela structures, so we'll leave them out until Novell (or | |
396 | whoever) gets their act together. */ | |
397 | ||
398 | /* Auxiliary vector. */ | |
399 | ||
400 | /* This vector is normally only used by the program interpreter. The | |
401 | usual definition in an ABI supplement uses the name auxv_t. The | |
402 | vector is not usually defined in a standard <elf.h> file, but it | |
403 | can't hurt. We rename it to avoid conflicts. The sizes of these | |
404 | types are an arrangement between the exec server and the program | |
405 | interpreter, so we don't fully specify them here. */ | |
406 | ||
407 | typedef struct | |
408 | { | |
409 | int a_type; /* Entry type */ | |
410 | union | |
411 | { | |
412 | long a_val; /* Integer value */ | |
413 | void *a_ptr; /* Pointer value */ | |
414 | void (*a_fcn) (); /* Function pointer value */ | |
415 | } a_un; | |
416 | } Elf32_auxv_t; | |
417 | ||
418 | /* Legal values for a_type (entry type). */ | |
419 | ||
420 | #define AT_NULL 0 /* End of vector */ | |
421 | #define AT_IGNORE 1 /* Entry should be ignored */ | |
422 | #define AT_EXECFD 2 /* File descriptor of program */ | |
423 | #define AT_PHDR 3 /* Program headers for program */ | |
424 | #define AT_PHENT 4 /* Size of program header entry */ | |
425 | #define AT_PHNUM 5 /* Number of program headers */ | |
426 | #define AT_PAGESZ 6 /* System page size */ | |
427 | #define AT_BASE 7 /* Base address of interpreter */ | |
428 | #define AT_FLAGS 8 /* Flags */ | |
429 | #define AT_ENTRY 9 /* Entry point of program */ | |
430 | #define AT_NOTELF 10 /* Program is not ELF */ | |
431 | #define AT_UID 11 /* Real uid */ | |
432 | #define AT_EUID 12 /* Effective uid */ | |
433 | #define AT_GID 13 /* Read gid */ | |
434 | #define AT_EGID 14 /* Effective gid */ | |
435 | ||
436 | /* Intel 80386 specific definitions. */ | |
437 | ||
438 | /* i386 relocs. */ | |
439 | ||
440 | #define R_386_NONE 0 /* No reloc */ | |
441 | #define R_386_32 1 /* Direct 32 bit */ | |
442 | #define R_386_PC32 2 /* PC relative 32 bit */ | |
443 | #define R_386_GOT32 3 /* 32 bit GOT entry */ | |
444 | #define R_386_PLT32 4 /* 32 bit PLT address */ | |
445 | #define R_386_COPY 5 /* Copy symbol at runtime */ | |
446 | #define R_386_GLOB_DAT 6 /* Create GOT entry */ | |
447 | #define R_386_JMP_SLOT 7 /* Create PLT entry */ | |
448 | #define R_386_RELATIVE 8 /* Adjust by program base */ | |
449 | #define R_386_GOTOFF 9 /* 32 bit offset to GOT */ | |
450 | #define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ | |
451 | ||
452 | /* SUN SPARC specific definitions. */ | |
453 | ||
454 | /* SPARC relocs. */ | |
455 | ||
456 | #define R_SPARC_NONE 0 /* No reloc */ | |
457 | #define R_SPARC_8 1 /* Direct 8 bit */ | |
458 | #define R_SPARC_16 2 /* Direct 16 bit */ | |
459 | #define R_SPARC_32 3 /* Direct 32 bit */ | |
460 | #define R_SPARC_DISP8 4 /* PC relative 8 bit */ | |
461 | #define R_SPARC_DISP16 5 /* PC relative 16 bit */ | |
462 | #define R_SPARC_DISP32 6 /* PC relative 32 bit */ | |
463 | #define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ | |
464 | #define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ | |
465 | #define R_SPARC_HI22 9 /* High 22 bit */ | |
466 | #define R_SPARC_22 10 /* Direct 22 bit */ | |
467 | #define R_SPARC_13 11 /* Direct 13 bit */ | |
468 | #define R_SPARC_LO10 12 /* Truncated 10 bit */ | |
469 | #define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ | |
470 | #define R_SPARC_GOT13 14 /* 13 bit GOT entry */ | |
471 | #define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ | |
472 | #define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ | |
473 | #define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ | |
474 | #define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ | |
475 | #define R_SPARC_COPY 19 /* Copy symbol at runtime */ | |
476 | #define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ | |
477 | #define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ | |
478 | #define R_SPARC_RELATIVE 22 /* Adjust by program base */ | |
479 | #define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ | |
480 | ||
481 | /* MIPS R3000 specific definitions. */ | |
482 | ||
483 | /* Legal values for e_flags field of Elf32_Ehdr. */ | |
484 | ||
485 | #define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ | |
486 | #define EF_MIPS_PIC 2 /* Contains PIC code */ | |
487 | #define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ | |
488 | #define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ | |
489 | ||
490 | /* Special section indices. */ | |
491 | ||
492 | #define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ | |
493 | #define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ | |
494 | #define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ | |
495 | ||
496 | /* Legal values for sh_type field of Elf32_Shdr. */ | |
497 | ||
498 | #define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ | |
499 | #define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ | |
500 | #define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ | |
501 | #define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ | |
502 | #define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information */ | |
503 | #define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ | |
504 | ||
505 | /* Legal values for sh_flags field of Elf32_Shdr. */ | |
506 | ||
507 | #define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ | |
508 | ||
509 | /* Entries found in sections of type SHT_MIPS_GPTAB. */ | |
510 | ||
511 | typedef union | |
512 | { | |
513 | struct | |
514 | { | |
515 | Elf32_Word gt_current_g_value; /* -G value used for compilation */ | |
516 | Elf32_Word gt_unused; /* Not used */ | |
517 | } gt_header; /* First entry in section */ | |
518 | struct | |
519 | { | |
520 | Elf32_Word gt_g_value; /* If this value were used for -G */ | |
521 | Elf32_Word gt_bytes; /* This many bytes would be used */ | |
522 | } gt_entry; /* Subsequent entries in section */ | |
523 | } Elf32_gptab; | |
524 | ||
525 | /* Entry found in sections of type SHT_MIPS_REGINFO. */ | |
526 | ||
527 | typedef struct | |
528 | { | |
529 | Elf32_Word ri_gprmask; /* General registers used */ | |
530 | Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ | |
531 | Elf32_Sword ri_gp_value; /* $gp register value */ | |
532 | } Elf32_RegInfo; | |
533 | ||
534 | /* MIPS relocs. */ | |
535 | ||
536 | #define R_MIPS_NONE 0 /* No reloc */ | |
537 | #define R_MIPS_16 1 /* Direct 16 bit */ | |
538 | #define R_MIPS_32 2 /* Direct 32 bit */ | |
539 | #define R_MIPS_REL32 3 /* PC relative 32 bit */ | |
540 | #define R_MIPS_26 4 /* Direct 26 bit shifted */ | |
541 | #define R_MIPS_HI16 5 /* High 16 bit */ | |
542 | #define R_MIPS_LO16 6 /* Low 16 bit */ | |
543 | #define R_MIPS_GPREL16 7 /* GP relative 16 bit */ | |
544 | #define R_MIPS_LITERAL 8 /* 16 bit literal entry */ | |
545 | #define R_MIPS_GOT16 9 /* 16 bit GOT entry */ | |
546 | #define R_MIPS_PC16 10 /* PC relative 16 bit */ | |
547 | #define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ | |
548 | #define R_MIPS_GPREL32 12 /* GP relative 32 bit */ | |
549 | ||
550 | /* Legal values for p_type field of Elf32_Phdr. */ | |
551 | ||
273d56ce | 552 | #define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ |
28f540f4 RM |
553 | |
554 | /* Legal values for d_tag field of Elf32_Dyn. */ | |
555 | ||
556 | #define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ | |
557 | #define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ | |
558 | #define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ | |
559 | #define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ | |
560 | #define DT_MIPS_FLAGS 0x70000005 /* Flags */ | |
561 | #define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ | |
562 | #define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ | |
563 | #define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ | |
564 | #define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ | |
565 | #define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ | |
566 | #define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ | |
567 | #define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ | |
568 | #define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ | |
569 | #define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ | |
570 | #define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ | |
571 | ||
572 | /* Legal values for DT_MIPS_FLAG Elf32_Dyn entry. */ | |
573 | ||
574 | #define RHF_NONE 0 /* No flags */ | |
575 | #define RHF_QUICKSTART (1 << 0) /* Use quickstart */ | |
576 | #define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ | |
577 | #define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ | |
578 | ||
579 | /* Entries found in sections of type SHT_MIPS_LIBLIST. */ | |
580 | ||
581 | typedef struct | |
582 | { | |
583 | Elf32_Word l_name; /* Name (string table index) */ | |
584 | Elf32_Word l_time_stamp; /* Timestamp */ | |
585 | Elf32_Word l_checksum; /* Checksum */ | |
586 | Elf32_Word l_version; /* Interface version */ | |
587 | Elf32_Word l_flags; /* Flags */ | |
588 | } Elf32_Lib; | |
589 | ||
590 | /* Legal values for l_flags. */ | |
591 | ||
592 | #define LL_EXACT_MATCH (1 << 0) /* Require exact match */ | |
593 | #define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ | |
594 | ||
595 | /* Entries found in sections of type SHT_MIPS_CONFLICT. */ | |
596 | ||
597 | typedef Elf32_Addr Elf32_Conflict; | |
598 | ||
599 | ||
600 | #endif /* elf.h */ |