1 #ifndef __ELF_H__
2 #define __ELF_H__
3 #include <stdint.h>
4
5 #define EI_NIDENT 16
6
7 typedef uint32_t elf32_word;
8 typedef int32_t elf32_sword;
9 typedef uint16_t elf32_half;
10 typedef uint32_t elf32_off;
11 typedef uint32_t elf32_addr;
12
13 struct elf32_ehdr {
14 unsigned char e_ident[EI_NIDENT];
15 elf32_half e_type;
16 elf32_half e_machine;
17 elf32_word e_version;
18 elf32_addr e_entry;
19 elf32_off e_phoff;
20 elf32_off e_shoff;
21 elf32_word e_flags;
22 elf32_half e_ehsize;
23 elf32_half e_phentsize;
24 elf32_half e_phnum;
25 elf32_half e_shentsize;
26 elf32_half e_shnum;
27 elf32_half e_shstrndx;
28 };
29
30
31 #define ET_NONE 0
32 #define ET_REL 1
33 #define ET_EXEC 2
34 #define ET_DYN 3
35 #define ET_CORE 4
36
37 struct elf32_shdr {
38 elf32_word sh_name;
39 elf32_word sh_type;
40 elf32_word sh_flags;
41 elf32_addr sh_addr;
42 elf32_off sh_offset;
43 elf32_word sh_size;
44 elf32_word sh_link;
45 elf32_word sh_info;
46 elf32_word sh_addralign;
47 elf32_word sh_entsize;
48 };
49
50
51 #define SHT_NULL 0
52 #define SHT_PROGBITS 1
53 #define SHT_SYMTAB 2
54 #define SHT_STRTAB 3
55 #define SHT_RELA 4
56 #define SHT_HASH 5
57 #define SHT_DYNAMIC 6
58 #define SHT_NOTE 7
59 #define SHT_NOBITS 8
60 #define SHT_REL 9
61 #define SHT_SHLIB 10
62 #define SHT_DYNSYM 11
63 #define SHT_LOPROC 0x70000000
64 #define SHT_HIPROC 0x7fffffff
65 #define SHT_LOUSER 0x80000000
66 #define SHT_HIUSER 0xffffffff
67
68
69 #define STB_LOCAL 0
70 #define STB_GLOBAL 1
71 #define STB_WEAK 2
72
73 #define STT_NOTYPE 0
74 #define STT_OBJECT 1
75 #define STT_FUNC 2
76 #define STT_SECTION 3
77 #define STT_FILE 4
78 #define STT_COMMON 5
79 #define STT_TLS 6
80
81
82 struct elf32_rel {
83 elf32_addr r_offset;
84 elf32_word r_info;
85 };
86
87 struct elf32_rela {
88 elf32_addr r_offset;
89 elf32_word r_info;
90 elf32_sword r_addend;
91 };
92
93 struct elf32_sym {
94 elf32_word st_name;
95 elf32_addr st_value;
96 elf32_word st_size;
97 unsigned char st_info;
98 unsigned char st_other;
99 elf32_half st_shndx;
100 };
101
102 #define ELF32_R_SYM(info) ((info) >> 8)
103 #define ELF32_R_TYPE(info) ((unsigned char)(info))
104 #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
105
106
107
108 #define R_ARM_PC24 1
109 #define R_ARM_ABS32 2
110 #define R_ARM_THM_CALL 10
111 #define R_ARM_PLT32 27
112 #define R_ARM_CALL 28
113 #define R_ARM_JUMP24 29
114 #define R_ARM_THM_JUMP24 30
115 #define R_ARM_V4BX 40
116
117 #endif