4 #include <linux/types.h>
5 #include <linux/auxvec.h>
8 #ifndef elf_read_implies_exec
9 /* Executables for which elf_read_implies_exec() returns TRUE will
10 have the READ_IMPLIES_EXEC personality flag set automatically.
11 Override in asm/elf.h as needed. */
12 # define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
15 /* 32-bit ELF base types. */
16 typedef __u32 Elf32_Addr
;
17 typedef __u16 Elf32_Half
;
18 typedef __u32 Elf32_Off
;
19 typedef __s32 Elf32_Sword
;
20 typedef __u32 Elf32_Word
;
22 /* 64-bit ELF base types. */
23 typedef __u64 Elf64_Addr
;
24 typedef __u16 Elf64_Half
;
25 typedef __s16 Elf64_SHalf
;
26 typedef __u64 Elf64_Off
;
27 typedef __s32 Elf64_Sword
;
28 typedef __u32 Elf64_Word
;
29 typedef __u64 Elf64_Xword
;
30 typedef __s64 Elf64_Sxword
;
32 /* These constants are for the segment types stored in the image headers */
40 #define PT_TLS 7 /* Thread local storage segment */
41 #define PT_LOOS 0x60000000 /* OS-specific */
42 #define PT_HIOS 0x6fffffff /* OS-specific */
43 #define PT_LOPROC 0x70000000
44 #define PT_HIPROC 0x7fffffff
45 #define PT_GNU_EH_FRAME 0x6474e550
47 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
49 /* These constants define the different elf file types */
55 #define ET_LOPROC 0xff00
56 #define ET_HIPROC 0xffff
58 /* These constants define the various ELF target machines */
65 #define EM_486 6 /* Perhaps disused */
68 #define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
70 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
72 #define EM_PARISC 15 /* HPPA */
74 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
76 #define EM_PPC 20 /* PowerPC */
77 #define EM_PPC64 21 /* PowerPC64 */
79 #define EM_SH 42 /* SuperH */
81 #define EM_SPARCV9 43 /* SPARC v9 64-bit */
83 #define EM_IA_64 50 /* HP/Intel IA-64 */
85 #define EM_X86_64 62 /* AMD x86-64 */
87 #define EM_S390 22 /* IBM S/390 */
89 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
91 #define EM_V850 87 /* NEC v850 */
93 #define EM_M32R 88 /* Renesas M32R */
95 #define EM_H8_300 46 /* Renesas H8/300,300H,H8S */
98 * This is an interim value that we will use until the committee comes
99 * up with a final number.
101 #define EM_ALPHA 0x9026
103 /* Bogus old v850 magic number, used by old tools. */
104 #define EM_CYGNUS_V850 0x9080
106 /* Bogus old m32r magic number, used by old tools. */
107 #define EM_CYGNUS_M32R 0x9041
110 * This is the old interim value for S/390 architecture
112 #define EM_S390_OLD 0xA390
114 #define EM_FRV 0x5441 /* Fujitsu FR-V */
116 /* This is the info that is needed to parse the dynamic section of the file */
119 #define DT_PLTRELSZ 2
133 #define DT_SYMBOLIC 16
139 #define DT_TEXTREL 22
141 #define DT_LOPROC 0x70000000
142 #define DT_HIPROC 0x7fffffff
144 /* This info is needed when parsing the symbol table */
152 #define STT_SECTION 3
155 #define ELF_ST_BIND(x) ((x) >> 4)
156 #define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
157 #define ELF32_ST_BIND(x) ELF_ST_BIND(x)
158 #define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
159 #define ELF64_ST_BIND(x) ELF_ST_BIND(x)
160 #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
162 typedef struct dynamic
{
171 Elf64_Sxword d_tag
; /* entry tag value */
178 /* The following are used with relocations */
179 #define ELF32_R_SYM(x) ((x) >> 8)
180 #define ELF32_R_TYPE(x) ((x) & 0xff)
182 #define ELF64_R_SYM(i) ((i) >> 32)
183 #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
185 typedef struct elf32_rel
{
190 typedef struct elf64_rel
{
191 Elf64_Addr r_offset
; /* Location at which to apply the action */
192 Elf64_Xword r_info
; /* index and type of relocation */
195 typedef struct elf32_rela
{
198 Elf32_Sword r_addend
;
201 typedef struct elf64_rela
{
202 Elf64_Addr r_offset
; /* Location at which to apply the action */
203 Elf64_Xword r_info
; /* index and type of relocation */
204 Elf64_Sxword r_addend
; /* Constant addend used to compute value */
207 typedef struct elf32_sym
{
211 unsigned char st_info
;
212 unsigned char st_other
;
216 typedef struct elf64_sym
{
217 Elf64_Word st_name
; /* Symbol name, index in string tbl */
218 unsigned char st_info
; /* Type and binding attributes */
219 unsigned char st_other
; /* No defined meaning, 0 */
220 Elf64_Half st_shndx
; /* Associated section index */
221 Elf64_Addr st_value
; /* Value of the symbol */
222 Elf64_Xword st_size
; /* Associated symbol size */
228 typedef struct elf32_hdr
{
229 unsigned char e_ident
[EI_NIDENT
];
231 Elf32_Half e_machine
;
232 Elf32_Word e_version
;
233 Elf32_Addr e_entry
; /* Entry point */
238 Elf32_Half e_phentsize
;
240 Elf32_Half e_shentsize
;
242 Elf32_Half e_shstrndx
;
245 typedef struct elf64_hdr
{
246 unsigned char e_ident
[16]; /* ELF "magic number" */
248 Elf64_Half e_machine
;
249 Elf64_Word e_version
;
250 Elf64_Addr e_entry
; /* Entry point virtual address */
251 Elf64_Off e_phoff
; /* Program header table file offset */
252 Elf64_Off e_shoff
; /* Section header table file offset */
255 Elf64_Half e_phentsize
;
257 Elf64_Half e_shentsize
;
259 Elf64_Half e_shstrndx
;
262 /* These constants define the permissions on sections in the program
268 typedef struct elf32_phdr
{
279 typedef struct elf64_phdr
{
282 Elf64_Off p_offset
; /* Segment file offset */
283 Elf64_Addr p_vaddr
; /* Segment virtual address */
284 Elf64_Addr p_paddr
; /* Segment physical address */
285 Elf64_Xword p_filesz
; /* Segment size in file */
286 Elf64_Xword p_memsz
; /* Segment size in memory */
287 Elf64_Xword p_align
; /* Segment alignment, file & memory */
292 #define SHT_PROGBITS 1
297 #define SHT_DYNAMIC 6
302 #define SHT_DYNSYM 11
304 #define SHT_LOPROC 0x70000000
305 #define SHT_HIPROC 0x7fffffff
306 #define SHT_LOUSER 0x80000000
307 #define SHT_HIUSER 0xffffffff
310 #define SHF_WRITE 0x1
311 #define SHF_ALLOC 0x2
312 #define SHF_EXECINSTR 0x4
313 #define SHF_MASKPROC 0xf0000000
315 /* special section indexes */
317 #define SHN_LORESERVE 0xff00
318 #define SHN_LOPROC 0xff00
319 #define SHN_HIPROC 0xff1f
320 #define SHN_ABS 0xfff1
321 #define SHN_COMMON 0xfff2
322 #define SHN_HIRESERVE 0xffff
333 Elf32_Word sh_addralign
;
334 Elf32_Word sh_entsize
;
337 typedef struct elf64_shdr
{
338 Elf64_Word sh_name
; /* Section name, index in string tbl */
339 Elf64_Word sh_type
; /* Type of section */
340 Elf64_Xword sh_flags
; /* Miscellaneous section attributes */
341 Elf64_Addr sh_addr
; /* Section virtual addr at execution */
342 Elf64_Off sh_offset
; /* Section file offset */
343 Elf64_Xword sh_size
; /* Size of section in bytes */
344 Elf64_Word sh_link
; /* Index of another section */
345 Elf64_Word sh_info
; /* Additional section information */
346 Elf64_Xword sh_addralign
; /* Section alignment */
347 Elf64_Xword sh_entsize
; /* Entry size if section holds table */
350 #define EI_MAG0 0 /* e_ident[] indexes */
360 #define ELFMAG0 0x7f /* EI_MAG */
364 #define ELFMAG "\177ELF"
367 #define ELFCLASSNONE 0 /* EI_CLASS */
370 #define ELFCLASSNUM 3
372 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
373 #define ELFDATA2LSB 1
374 #define ELFDATA2MSB 2
376 #define EV_NONE 0 /* e_version, EI_VERSION */
380 #define ELFOSABI_NONE 0
381 #define ELFOSABI_LINUX 3
384 #define ELF_OSABI ELFOSABI_NONE
387 /* Notes used in ET_CORE */
388 #define NT_PRSTATUS 1
390 #define NT_PRPSINFO 3
391 #define NT_TASKSTRUCT 4
393 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
396 /* Note header in a PT_NOTE section */
397 typedef struct elf32_note
{
398 Elf32_Word n_namesz
; /* Name size */
399 Elf32_Word n_descsz
; /* Content size */
400 Elf32_Word n_type
; /* Content type */
403 /* Note header in a PT_NOTE section */
404 typedef struct elf64_note
{
405 Elf64_Word n_namesz
; /* Name size */
406 Elf64_Word n_descsz
; /* Content size */
407 Elf64_Word n_type
; /* Content type */
410 #if ELF_CLASS == ELFCLASS32
412 extern Elf32_Dyn _DYNAMIC
[];
413 #define elfhdr elf32_hdr
414 #define elf_phdr elf32_phdr
415 #define elf_note elf32_note
419 extern Elf64_Dyn _DYNAMIC
[];
420 #define elfhdr elf64_hdr
421 #define elf_phdr elf64_phdr
422 #define elf_note elf64_note
427 #endif /* _LINUX_ELF_H */