2 * ELF register definitions..
7 typedef uint32_t elf_greg_t;
9 #define ELF_NGREG (sizeof (struct target_pt_regs) / sizeof(elf_greg_t))
10 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
12 typedef struct user_i387_struct elf_fpregset_t;
15 * This is used to ensure we don't load something for the wrong architecture.
17 #define elf_check_arch(x) ( ((x) == EM_386) || ((x) == EM_486) )
20 * These are used to set parameters in the core dumps.
22 #define ELF_CLASS ELFCLASS32
23 #define ELF_DATA ELFDATA2LSB;
24 #define ELF_ARCH EM_386
26 /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program
27 starts %edx contains a pointer to a function which might be
28 registered using `atexit'. This provides a mean for the
29 dynamic linker to call DT_FINI functions for shared libraries
30 that have been loaded before the code runs.
32 A value of 0 tells we have no such handler. */
33 #define ELF_PLAT_INIT(_r) _r->edx = 0
35 #define USE_ELF_CORE_DUMP
36 #define ELF_EXEC_PAGESIZE 4096
39 typedef uint32_t Elf32_Addr;
40 typedef uint16_t Elf32_Half;
41 typedef uint32_t Elf32_Off;
42 typedef int32_t Elf32_Sword;
43 typedef uint32_t Elf32_Word;
45 /* These constants are for the segment types stored in the image headers */
53 #define PT_LOPROC 0x70000000
54 #define PT_HIPROC 0x7fffffff
56 /* These constants define the different elf file types */
65 /* These constants define the various ELF target machines */
72 #define EM_486 6 /* Perhaps disused */
75 #define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
77 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
79 #define EM_SPARC64 11 /* SPARC v9 (not official) 64-bit */
81 #define EM_PARISC 15 /* HPPA */
83 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
85 #define EM_PPC 20 /* PowerPC */
88 * This is an interim value that we will use until the committee comes
89 * up with a final number.
91 #define EM_ALPHA 0x9026
94 /* This is the info that is needed to parse the dynamic section of the file */
111 #define DT_SYMBOLIC 16
117 #define DT_TEXTREL 22
119 #define DT_LOPROC 0x70000000
120 #define DT_HIPROC 0x7fffffff
122 /* This info is needed when parsing the symbol table */
130 #define STT_SECTION 3
133 #define ELF32_ST_BIND(x) ((x) >> 4)
134 #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
136 /* Symbolic values for the entries in the auxiliary table
137 put on the initial stack */
138 #define AT_NULL 0 /* end of vector */
139 #define AT_IGNORE 1 /* entry should be ignored */
140 #define AT_EXECFD 2 /* file descriptor of program */
141 #define AT_PHDR 3 /* program headers for program */
142 #define AT_PHENT 4 /* size of program header entry */
143 #define AT_PHNUM 5 /* number of program headers */
144 #define AT_PAGESZ 6 /* system page size */
145 #define AT_BASE 7 /* base address of interpreter */
146 #define AT_FLAGS 8 /* flags */
147 #define AT_ENTRY 9 /* entry point of program */
148 #define AT_NOTELF 10 /* program is not ELF */
149 #define AT_UID 11 /* real uid */
150 #define AT_EUID 12 /* effective uid */
151 #define AT_GID 13 /* real gid */
152 #define AT_EGID 14 /* effective gid */
155 typedef struct dynamic{
164 unsigned long long d_tag; /* entry tag value */
166 unsigned long long d_val;
167 unsigned long long d_ptr;
171 /* The following are used with relocations */
172 #define ELF32_R_SYM(x) ((x) >> 8)
173 #define ELF32_R_TYPE(x) ((x) & 0xff)
178 #define R_386_GOT32 3
179 #define R_386_PLT32 4
181 #define R_386_GLOB_DAT 6
182 #define R_386_JMP_SLOT 7
183 #define R_386_RELATIVE 8
184 #define R_386_GOTOFF 9
185 #define R_386_GOTPC 10
188 typedef struct elf32_rel {
193 typedef struct elf64_rel {
194 unsigned long long r_offset; /* Location at which to apply the action */
195 unsigned long long r_info; /* index and type of relocation */
198 typedef struct elf32_rela{
201 Elf32_Sword r_addend;
204 typedef struct elf64_rela {
205 unsigned long long r_offset; /* Location at which to apply the action */
206 unsigned long long r_info; /* index and type of relocation */
207 unsigned long long r_addend; /* Constant addend used to compute value */
210 typedef struct elf32_sym{
214 unsigned char st_info;
215 unsigned char st_other;
219 typedef struct elf64_sym {
220 unsigned int st_name; /* Symbol name, index in string tbl */
221 unsigned char st_info; /* Type and binding attributes */
222 unsigned char st_other; /* No defined meaning, 0 */
223 unsigned short st_shndx; /* Associated section index */
224 unsigned long long st_value; /* Value of the symbol */
225 unsigned long long st_size; /* Associated symbol size */
231 typedef struct elf32_hdr{
232 unsigned char e_ident[EI_NIDENT];
234 Elf32_Half e_machine;
235 Elf32_Word e_version;
236 Elf32_Addr e_entry; /* Entry point */
241 Elf32_Half e_phentsize;
243 Elf32_Half e_shentsize;
245 Elf32_Half e_shstrndx;
248 typedef struct elf64_hdr {
249 unsigned char e_ident[16]; /* ELF "magic number" */
251 short unsigned int e_machine;
253 unsigned long long e_entry; /* Entry point virtual address */
254 unsigned long long e_phoff; /* Program header table file offset */
255 unsigned long long e_shoff; /* Section header table file offset */
258 short int e_phentsize;
260 short int e_shentsize;
262 short int e_shstrndx;
265 /* These constants define the permissions on sections in the program
271 typedef struct elf32_phdr{
282 typedef struct elf64_phdr {
285 unsigned long long p_offset; /* Segment file offset */
286 unsigned long long p_vaddr; /* Segment virtual address */
287 unsigned long long p_paddr; /* Segment physical address */
288 unsigned long long p_filesz; /* Segment size in file */
289 unsigned long long p_memsz; /* Segment size in memory */
290 unsigned long long p_align; /* Segment alignment, file & memory */
295 #define SHT_PROGBITS 1
300 #define SHT_DYNAMIC 6
305 #define SHT_DYNSYM 11
307 #define SHT_LOPROC 0x70000000
308 #define SHT_HIPROC 0x7fffffff
309 #define SHT_LOUSER 0x80000000
310 #define SHT_HIUSER 0xffffffff
313 #define SHF_WRITE 0x1
314 #define SHF_ALLOC 0x2
315 #define SHF_EXECINSTR 0x4
316 #define SHF_MASKPROC 0xf0000000
318 /* special section indexes */
320 #define SHN_LORESERVE 0xff00
321 #define SHN_LOPROC 0xff00
322 #define SHN_HIPROC 0xff1f
323 #define SHN_ABS 0xfff1
324 #define SHN_COMMON 0xfff2
325 #define SHN_HIRESERVE 0xffff
336 Elf32_Word sh_addralign;
337 Elf32_Word sh_entsize;
340 typedef struct elf64_shdr {
341 unsigned int sh_name; /* Section name, index in string tbl */
342 unsigned int sh_type; /* Type of section */
343 unsigned long long sh_flags; /* Miscellaneous section attributes */
344 unsigned long long sh_addr; /* Section virtual addr at execution */
345 unsigned long long sh_offset; /* Section file offset */
346 unsigned long long sh_size; /* Size of section in bytes */
347 unsigned int sh_link; /* Index of another section */
348 unsigned int sh_info; /* Additional section information */
349 unsigned long long sh_addralign; /* Section alignment */
350 unsigned long long sh_entsize; /* Entry size if section holds table */
353 #define EI_MAG0 0 /* e_ident[] indexes */
362 #define ELFMAG0 0x7f /* EI_MAG */
366 #define ELFMAG "\177ELF"
369 #define ELFCLASSNONE 0 /* EI_CLASS */
372 #define ELFCLASSNUM 3
374 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
375 #define ELFDATA2LSB 1
376 #define ELFDATA2MSB 2
378 #define EV_NONE 0 /* e_version, EI_VERSION */
382 /* Notes used in ET_CORE */
383 #define NT_PRSTATUS 1
385 #define NT_PRPSINFO 3
386 #define NT_TASKSTRUCT 4
388 /* Note header in a PT_NOTE section */
389 typedef struct elf32_note {
390 Elf32_Word n_namesz; /* Name size */
391 Elf32_Word n_descsz; /* Content size */
392 Elf32_Word n_type; /* Content type */
395 /* Note header in a PT_NOTE section */
397 * For now we use the 32 bit version of the structure until we figure
398 * out whether we need anything better. Note - on the Alpha, "unsigned int"
401 typedef struct elf64_note {
402 unsigned int n_namesz; /* Name size */
403 unsigned int n_descsz; /* Content size */
404 unsigned int n_type; /* Content type */
407 #define ELF_START_MMAP 0x80000000
409 #if ELF_CLASS == ELFCLASS32
411 extern Elf32_Dyn _DYNAMIC [];
412 #define elfhdr elf32_hdr
413 #define elf_phdr elf32_phdr
414 #define elf_note elf32_note
418 extern Elf64_Dyn _DYNAMIC [];
419 #define elfhdr elf64_hdr
420 #define elf_phdr elf64_phdr
421 #define elf_note elf64_note