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