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