4 #include <linux/types.h>
7 #ifndef elf_read_implies_exec
8 /* Executables for which elf_read_implies_exec() returns TRUE will
9 have the READ_IMPLIES_EXEC personality flag set automatically.
10 Override in asm/elf.h as needed. */
11 # define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
14 /* 32-bit ELF base types. */
15 typedef __u32 Elf32_Addr;
16 typedef __u16 Elf32_Half;
17 typedef __u32 Elf32_Off;
18 typedef __s32 Elf32_Sword;
19 typedef __u32 Elf32_Word;
21 /* 64-bit ELF base types. */
22 typedef __u64 Elf64_Addr;
23 typedef __u16 Elf64_Half;
24 typedef __s16 Elf64_SHalf;
25 typedef __u64 Elf64_Off;
26 typedef __s32 Elf64_Sword;
27 typedef __u32 Elf64_Word;
28 typedef __u64 Elf64_Xword;
29 typedef __s64 Elf64_Sxword;
31 /* These constants are for the segment types stored in the image headers */
39 #define PT_LOOS 0x60000000
40 #define PT_HIOS 0x6fffffff
41 #define PT_LOPROC 0x70000000
42 #define PT_HIPROC 0x7fffffff
43 #define PT_GNU_EH_FRAME 0x6474e550
45 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
47 /* These constants define the different elf file types */
53 #define ET_LOPROC 0xff00
54 #define ET_HIPROC 0xffff
56 /* These constants define the various ELF target machines */
63 #define EM_486 6 /* Perhaps disused */
66 #define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
68 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
70 #define EM_PARISC 15 /* HPPA */
72 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
74 #define EM_PPC 20 /* PowerPC */
75 #define EM_PPC64 21 /* PowerPC64 */
77 #define EM_SH 42 /* SuperH */
79 #define EM_SPARCV9 43 /* SPARC v9 64-bit */
81 #define EM_IA_64 50 /* HP/Intel IA-64 */
83 #define EM_X86_64 62 /* AMD x86-64 */
85 #define EM_S390 22 /* IBM S/390 */
87 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
89 #define EM_V850 87 /* NEC v850 */
91 #define EM_H8_300 46 /* Hitachi H8/300,300H,H8S */
94 * This is an interim value that we will use until the committee comes
95 * up with a final number.
97 #define EM_ALPHA 0x9026
99 /* Bogus old v850 magic number, used by old tools. */
100 #define EM_CYGNUS_V850 0x9080
103 * This is the old interim value for S/390 architecture
105 #define EM_S390_OLD 0xA390
107 /* This is the info that is needed to parse the dynamic section of the file */
110 #define DT_PLTRELSZ 2
124 #define DT_SYMBOLIC 16
130 #define DT_TEXTREL 22
132 #define DT_LOPROC 0x70000000
133 #define DT_HIPROC 0x7fffffff
135 /* This info is needed when parsing the symbol table */
143 #define STT_SECTION 3
146 #define ELF_ST_BIND(x) ((x) >> 4)
147 #define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
148 #define ELF32_ST_BIND(x) ELF_ST_BIND(x)
149 #define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
150 #define ELF64_ST_BIND(x) ELF_ST_BIND(x)
151 #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
153 /* Symbolic values for the entries in the auxiliary table
154 put on the initial stack */
155 #define AT_NULL 0 /* end of vector */
156 #define AT_IGNORE 1 /* entry should be ignored */
157 #define AT_EXECFD 2 /* file descriptor of program */
158 #define AT_PHDR 3 /* program headers for program */
159 #define AT_PHENT 4 /* size of program header entry */
160 #define AT_PHNUM 5 /* number of program headers */
161 #define AT_PAGESZ 6 /* system page size */
162 #define AT_BASE 7 /* base address of interpreter */
163 #define AT_FLAGS 8 /* flags */
164 #define AT_ENTRY 9 /* entry point of program */
165 #define AT_NOTELF 10 /* program is not ELF */
166 #define AT_UID 11 /* real uid */
167 #define AT_EUID 12 /* effective uid */
168 #define AT_GID 13 /* real gid */
169 #define AT_EGID 14 /* effective gid */
170 #define AT_PLATFORM 15 /* string identifying CPU for optimizations */
171 #define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
172 #define AT_CLKTCK 17 /* frequency at which times() increments */
174 #define AT_SECURE 23 /* secure mode boolean */
176 typedef struct dynamic{
185 Elf64_Sxword d_tag; /* entry tag value */
192 /* The following are used with relocations */
193 #define ELF32_R_SYM(x) ((x) >> 8)
194 #define ELF32_R_TYPE(x) ((x) & 0xff)
196 #define ELF64_R_SYM(i) ((i) >> 32)
197 #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
199 typedef struct elf32_rel {
204 typedef struct elf64_rel {
205 Elf64_Addr r_offset; /* Location at which to apply the action */
206 Elf64_Xword r_info; /* index and type of relocation */
209 typedef struct elf32_rela{
212 Elf32_Sword r_addend;
215 typedef struct elf64_rela {
216 Elf64_Addr r_offset; /* Location at which to apply the action */
217 Elf64_Xword r_info; /* index and type of relocation */
218 Elf64_Sxword r_addend; /* Constant addend used to compute value */
221 typedef struct elf32_sym{
225 unsigned char st_info;
226 unsigned char st_other;
230 typedef struct elf64_sym {
231 Elf64_Word st_name; /* Symbol name, index in string tbl */
232 unsigned char st_info; /* Type and binding attributes */
233 unsigned char st_other; /* No defined meaning, 0 */
234 Elf64_Half st_shndx; /* Associated section index */
235 Elf64_Addr st_value; /* Value of the symbol */
236 Elf64_Xword st_size; /* Associated symbol size */
242 typedef struct elf32_hdr{
243 unsigned char e_ident[EI_NIDENT];
245 Elf32_Half e_machine;
246 Elf32_Word e_version;
247 Elf32_Addr e_entry; /* Entry point */
252 Elf32_Half e_phentsize;
254 Elf32_Half e_shentsize;
256 Elf32_Half e_shstrndx;
259 typedef struct elf64_hdr {
260 unsigned char e_ident[16]; /* ELF "magic number" */
262 Elf64_Half e_machine;
263 Elf64_Word e_version;
264 Elf64_Addr e_entry; /* Entry point virtual address */
265 Elf64_Off e_phoff; /* Program header table file offset */
266 Elf64_Off e_shoff; /* Section header table file offset */
269 Elf64_Half e_phentsize;
271 Elf64_Half e_shentsize;
273 Elf64_Half e_shstrndx;
276 /* These constants define the permissions on sections in the program
282 typedef struct elf32_phdr{
293 typedef struct elf64_phdr {
296 Elf64_Off p_offset; /* Segment file offset */
297 Elf64_Addr p_vaddr; /* Segment virtual address */
298 Elf64_Addr p_paddr; /* Segment physical address */
299 Elf64_Xword p_filesz; /* Segment size in file */
300 Elf64_Xword p_memsz; /* Segment size in memory */
301 Elf64_Xword p_align; /* Segment alignment, file & memory */
306 #define SHT_PROGBITS 1
311 #define SHT_DYNAMIC 6
316 #define SHT_DYNSYM 11
318 #define SHT_LOPROC 0x70000000
319 #define SHT_HIPROC 0x7fffffff
320 #define SHT_LOUSER 0x80000000
321 #define SHT_HIUSER 0xffffffff
324 #define SHF_WRITE 0x1
325 #define SHF_ALLOC 0x2
326 #define SHF_EXECINSTR 0x4
327 #define SHF_MASKPROC 0xf0000000
329 /* special section indexes */
331 #define SHN_LORESERVE 0xff00
332 #define SHN_LOPROC 0xff00
333 #define SHN_HIPROC 0xff1f
334 #define SHN_ABS 0xfff1
335 #define SHN_COMMON 0xfff2
336 #define SHN_HIRESERVE 0xffff
347 Elf32_Word sh_addralign;
348 Elf32_Word sh_entsize;
351 typedef struct elf64_shdr {
352 Elf64_Word sh_name; /* Section name, index in string tbl */
353 Elf64_Word sh_type; /* Type of section */
354 Elf64_Xword sh_flags; /* Miscellaneous section attributes */
355 Elf64_Addr sh_addr; /* Section virtual addr at execution */
356 Elf64_Off sh_offset; /* Section file offset */
357 Elf64_Xword sh_size; /* Size of section in bytes */
358 Elf64_Word sh_link; /* Index of another section */
359 Elf64_Word sh_info; /* Additional section information */
360 Elf64_Xword sh_addralign; /* Section alignment */
361 Elf64_Xword sh_entsize; /* Entry size if section holds table */
364 #define EI_MAG0 0 /* e_ident[] indexes */
374 #define ELFMAG0 0x7f /* EI_MAG */
378 #define ELFMAG "\177ELF"
381 #define ELFCLASSNONE 0 /* EI_CLASS */
384 #define ELFCLASSNUM 3
386 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
387 #define ELFDATA2LSB 1
388 #define ELFDATA2MSB 2
390 #define EV_NONE 0 /* e_version, EI_VERSION */
394 #define ELFOSABI_NONE 0
395 #define ELFOSABI_LINUX 3
398 #define ELF_OSABI ELFOSABI_NONE
401 /* Notes used in ET_CORE */
402 #define NT_PRSTATUS 1
404 #define NT_PRPSINFO 3
405 #define NT_TASKSTRUCT 4
407 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
410 /* Note header in a PT_NOTE section */
411 typedef struct elf32_note {
412 Elf32_Word n_namesz; /* Name size */
413 Elf32_Word n_descsz; /* Content size */
414 Elf32_Word n_type; /* Content type */
417 /* Note header in a PT_NOTE section */
418 typedef struct elf64_note {
419 Elf64_Word n_namesz; /* Name size */
420 Elf64_Word n_descsz; /* Content size */
421 Elf64_Word n_type; /* Content type */
424 #if ELF_CLASS == ELFCLASS32
426 extern Elf32_Dyn _DYNAMIC [];
427 #define elfhdr elf32_hdr
428 #define elf_phdr elf32_phdr
429 #define elf_note elf32_note
433 extern Elf64_Dyn _DYNAMIC [];
434 #define elfhdr elf64_hdr
435 #define elf_phdr elf64_phdr
436 #define elf_note elf64_note
441 #endif /* _LINUX_ELF_H */