4 \brief ELF Exeutable Loader
\r
10 \struct elf_header_s
\r
11 \brief ELF File Header
\r
13 struct sElf32_Ehdr {
\r
15 char ident[16]; //!< Identifier Bytes
\r
23 Uint16 filetype; //!< File Type
\r
24 Uint16 machine; //!< Machine / Arch
\r
25 Uint32 version; //!< Version (File?)
\r
26 Uint32 entrypoint; //!< Entry Point
\r
27 Uint32 phoff; //!< Program Header Offset
\r
28 Uint32 shoff; //!< Section Header Offset
\r
29 Uint32 flags; //!< Flags
\r
30 Uint16 headersize; //!< Header Size
\r
31 Uint16 phentsize; //!< Program Header Entry Size
\r
32 Uint16 phentcount; //!< Program Header Entry Count
\r
33 Uint16 shentsize; //!< Section Header Entry Size
\r
34 Uint16 shentcount; //!< Section Header Entry Count
\r
35 Uint16 shstrindex; //!< Section Header String Table Index
\r
39 \name Executable Types
\r
42 #define ET_NONE 0 //!< NULL Type
\r
43 #define ET_REL 1 //!< Relocatable (Object)
\r
44 #define ET_EXEC 2 //!< Executable
\r
45 #define ET_DYN 3 //!< Dynamic Library
\r
46 #define ET_CORE 4 //!< Core?
\r
47 #define ET_LOPROC 0xFF00 //!< Low Impl Defined
\r
48 #define ET_HIPROC 0xFFFF //!< High Impl Defined
\r
55 #define SHN_UNDEF 0 //!< Undefined Section
\r
56 #define SHN_LORESERVE 0xFF00 //!< Low Reserved
\r
57 #define SHN_LOPROC 0xFF00 //!< Low Impl Defined
\r
58 #define SHN_HIPROC 0xFF1F //!< High Impl Defined
\r
59 #define SHN_ABS 0xFFF1 //!< Absolute Address (Base: 0, Size: -1)
\r
60 #define SHN_COMMON 0xFFF2 //!< Common
\r
61 #define SHN_HIRESERVE 0xFFFF //!< High Reserved
\r
65 \enum eElfSectionTypes
\r
66 \brief ELF Section Types
\r
68 enum eElfSectionTypes {
\r
82 SHT_LOPROC = 0x70000000,
\r
83 SHT_HIPROC = 0x7fffffff,
\r
84 SHT_LOUSER = 0x80000000,
\r
85 SHT_HIUSER = 0xffffffff
\r
88 #define SHF_WRITE 0x1
\r
89 #define SHF_ALLOC 0x2
\r
90 #define SHF_EXECINSTR 0x4
\r
91 #define SHF_MASKPROC 0xf0000000
\r
93 struct sElf32_Shent {
\r
111 Uint32 value; //Address
\r
117 #define STN_UNDEF 0 // Undefined Symbol
\r
127 PT_LOPROC = 0x70000000,
\r
128 PT_HIPROC = 0x7fffffff
\r
131 struct sElf32_Phdr {
\r
142 struct elf32_rel_s {
\r
147 struct elf32_rela_s {
\r
154 R_386_NONE=0, // none
\r
156 R_386_PC32, // S+A-P
\r
157 R_386_GOT32, // G+A-P
\r
158 R_386_PLT32, // L+A-P
\r
159 R_386_COPY, // none
\r
160 R_386_GLOB_DAT, // S
\r
161 R_386_JMP_SLOT, // S
\r
162 R_386_RELATIVE, // B+A
\r
163 R_386_GOTOFF, // S+A-GOT
\r
164 R_386_GOTPC, // GOT+A-P
\r
168 #define ELF32_R_SYM(i) ((i)>>8) // Takes an info value and returns a symbol index
\r
169 #define ELF32_R_TYPE(i) ((i)&0xFF) // Takes an info value and returns a type
\r
170 #define ELF32_R_INFO(s,t) (((s)<<8)+((t)&0xFF)) // Takes a type and symbol index and returns an info value
\r
172 struct elf32_dyn_s {
\r
174 Uint32 d_val; //Also d_ptr
\r
178 DT_NULL, //!< Marks End of list
\r
179 DT_NEEDED, //!< Offset in strtab to needed library
\r
180 DT_PLTRELSZ, //!< Size in bytes of PLT
\r
181 DT_PLTGOT, //!< Address of PLT/GOT
\r
182 DT_HASH, //!< Address of symbol hash table
\r
183 DT_STRTAB, //!< String Table address
\r
184 DT_SYMTAB, //!< Symbol Table address
\r
185 DT_RELA, //!< Relocation table address
\r
186 DT_RELASZ, //!< Size of relocation table
\r
187 DT_RELAENT, //!< Size of entry in relocation table
\r
188 DT_STRSZ, //!< Size of string table
\r
189 DT_SYMENT, //!< Size of symbol table entry
\r
190 DT_INIT, //!< Address of initialisation function
\r
191 DT_FINI, //!< Address of termination function
\r
192 DT_SONAME, //!< String table offset of so name
\r
193 DT_RPATH, //!< String table offset of library path
\r
194 DT_SYMBOLIC,//!< Reverse order of symbol searching for library, search libs first then executable
\r
195 DT_REL, //!< Relocation Entries (Elf32_Rel instead of Elf32_Rela)
\r
196 DT_RELSZ, //!< Size of above table (bytes)
\r
197 DT_RELENT, //!< Size of entry in above table
\r
198 DT_PLTREL, //!< Relocation entry of PLT
\r
199 DT_DEBUG, //!< Debugging Entry - Unknown contents
\r
200 DT_TEXTREL, //!< Indicates that modifcations to a non-writeable segment may occur
\r
201 DT_JMPREL, //!< Address of PLT only relocation entries
\r
202 DT_LOPROC = 0x70000000, //!< Low Definable
\r
203 DT_HIPROC = 0x7FFFFFFF //!< High Definable
\r
206 typedef struct sElf32_Ehdr Elf32_Ehdr;
\r
207 typedef struct sElf32_Phdr Elf32_Phdr;
\r
208 typedef struct sElf32_Shent Elf32_Shent;
\r
209 typedef struct elf_sym_s elf_symtab;
\r
210 typedef struct elf_sym_s Elf32_Sym;
\r
211 typedef struct elf32_rel_s Elf32_Rel;
\r
212 typedef struct elf32_rela_s Elf32_Rela;
\r
213 typedef struct elf32_dyn_s Elf32_Dyn;
\r
215 #endif // defined(_EXE_ELF_H)
\r