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