4 \brief ELF Exeutable Loader
13 \brief ELF File Header
16 Uint8 e_ident[16]; //!< Identifier Bytes
17 Uint16 filetype; //!< File Type
18 Uint16 machine; //!< Machine / Arch
19 Uint32 version; //!< Version (File?)
20 Uint32 entrypoint; //!< Entry Point
21 Uint32 phoff; //!< Program Header Offset
22 Uint32 shoff; //!< Section Header Offset
23 Uint32 flags; //!< Flags
24 Uint16 headersize; //!< Header Size
25 Uint16 phentsize; //!< Program Header Entry Size
26 Uint16 phentcount; //!< Program Header Entry Count
27 Uint16 shentsize; //!< Section Header Entry Size
28 Uint16 shentcount; //!< Section Header Entry Count
29 Uint16 shstrindex; //!< Section Header String Table Index
33 \name Executable Types
36 #define ET_NONE 0 //!< NULL Type
37 #define ET_REL 1 //!< Relocatable (Object)
38 #define ET_EXEC 2 //!< Executable
39 #define ET_DYN 3 //!< Dynamic Library
40 #define ET_CORE 4 //!< Core?
41 #define ET_LOPROC 0xFF00 //!< Low Impl Defined
42 #define ET_HIPROC 0xFFFF //!< High Impl Defined
49 #define SHN_UNDEF 0 //!< Undefined Section
50 #define SHN_LORESERVE 0xFF00 //!< Low Reserved
51 #define SHN_LOPROC 0xFF00 //!< Low Impl Defined
52 #define SHN_HIPROC 0xFF1F //!< High Impl Defined
53 #define SHN_ABS 0xFFF1 //!< Absolute Address (Base: 0, Size: -1)
54 #define SHN_COMMON 0xFFF2 //!< Common
55 #define SHN_HIRESERVE 0xFFFF //!< High Reserved
59 \enum eElfSectionTypes
60 \brief ELF Section Types
62 enum eElfSectionTypes {
76 SHT_LOPROC = 0x70000000,
77 SHT_HIPROC = 0x7fffffff,
78 SHT_LOUSER = 0x80000000,
79 SHT_HIUSER = 0xffffffff
84 #define SHF_EXECINSTR 0x4
85 #define SHF_MASKPROC 0xf0000000
102 Uint32 value; //Address
108 #define STN_UNDEF 0 // Undefined Symbol
118 PT_LOPROC = 0x70000000,
119 PT_HIPROC = 0x7fffffff
138 struct elf32_rela_s {
145 R_386_NONE=0, // none
148 R_386_GOT32, // G+A-P
149 R_386_PLT32, // L+A-P
153 R_386_RELATIVE, // B+A
154 R_386_GOTOFF, // S+A-GOT
155 R_386_GOTPC, // GOT+A-P
159 #define ELF32_R_SYM(i) ((i)>>8) // Takes an info value and returns a symbol index
160 #define ELF32_R_TYPE(i) ((i)&0xFF) // Takes an info value and returns a type
161 #define ELF32_R_INFO(s,t) (((s)<<8)+((t)&0xFF)) // Takes a type and symbol index and returns an info value
165 Uint32 d_val; //Also d_ptr
169 DT_NULL, //!< Marks End of list
170 DT_NEEDED, //!< Offset in strtab to needed library
171 DT_PLTRELSZ, //!< Size in bytes of PLT
172 DT_PLTGOT, //!< Address of PLT/GOT
173 DT_HASH, //!< Address of symbol hash table
174 DT_STRTAB, //!< String Table address
175 DT_SYMTAB, //!< Symbol Table address
176 DT_RELA, //!< Relocation table address
177 DT_RELASZ, //!< Size of relocation table
178 DT_RELAENT, //!< Size of entry in relocation table
179 DT_STRSZ, //!< Size of string table
180 DT_SYMENT, //!< Size of symbol table entry
181 DT_INIT, //!< Address of initialisation function
182 DT_FINI, //!< Address of termination function
183 DT_SONAME, //!< String table offset of so name
184 DT_RPATH, //!< String table offset of library path
185 DT_SYMBOLIC,//!< Reverse order of symbol searching for library, search libs first then executable
186 DT_REL, //!< Relocation Entries (Elf32_Rel instead of Elf32_Rela)
187 DT_RELSZ, //!< Size of above table (bytes)
188 DT_RELENT, //!< Size of entry in above table
189 DT_PLTREL, //!< Relocation entry of PLT
190 DT_DEBUG, //!< Debugging Entry - Unknown contents
191 DT_TEXTREL, //!< Indicates that modifcations to a non-writeable segment may occur
192 DT_JMPREL, //!< Address of PLT only relocation entries
193 DT_LOPROC = 0x70000000, //!< Low Definable
194 DT_HIPROC = 0x7FFFFFFF //!< High Definable
197 typedef struct sElf32_Ehdr Elf32_Ehdr;
198 typedef struct sElf32_Phdr Elf32_Phdr;
199 typedef struct sElf32_Shent Elf32_Shent;
200 typedef struct elf_sym_s elf_symtab;
201 typedef struct elf_sym_s Elf32_Sym;
202 typedef struct elf32_rel_s Elf32_Rel;
203 typedef struct elf32_rela_s Elf32_Rela;
204 typedef struct elf32_dyn_s Elf32_Dyn;
206 #endif // defined(_EXE_ELF_H)