/**\r
- Acess v1\r
- \file bin_elf.h\r
- \brief ELF Exeutable Loader\r
-*/\r
+ * \file elf.h\r
+ * \brief ELF Exeutable Loader\r
+ */\r
#ifndef _BIN_ELF_H\r
#define _BIN_ELF_H\r
\r
+typedef Uint16 Elf64_Half;\r
+typedef Uint32 Elf64_Word;\r
+typedef Uint64 Elf64_Addr;\r
+typedef Uint64 Elf64_Off;\r
+typedef Uint64 Elf64_Xword;\r
+\r
+enum e_ident_values\r
+{\r
+ EI_MAG0,\r
+ EI_MAG1,\r
+ EI_MAG2,\r
+ EI_MAG3,\r
+ EI_CLASS,\r
+ EI_DATA,\r
+ EI_VERSION,\r
+ EI_OSABI,\r
+ EI_ABIVERSION,\r
+ EI_PAD,\r
+ EI_NIDENT = 16,\r
+};\r
+\r
+#define ELFCLASS32 1\r
+#define ELFCLASS64 2\r
+\r
/**\r
- \struct elf_header_s\r
- \brief ELF File Header\r
-*/\r
-struct sElf32_Ehdr {\r
+ * \brief ELF File Header\r
+ */\r
+struct sElf32_Ehdr\r
+{\r
union {\r
char ident[16]; //!< Identifier Bytes\r
struct {\r
Uint16 shentsize; //!< Section Header Entry Size\r
Uint16 shentcount; //!< Section Header Entry Count\r
Uint16 shstrindex; //!< Section Header String Table Index\r
-};\r
+} __attribute__ ((packed));\r
+\r
+typedef struct\r
+{\r
+ unsigned char e_ident[16];\r
+ Elf64_Half e_type;\r
+ Elf64_Half e_machine;\r
+ Elf64_Word e_version;\r
+ Elf64_Addr e_entry;\r
+ Elf64_Off e_phoff;\r
+ Elf64_Off e_shoff;\r
+ Elf64_Word e_flags;\r
+ Elf64_Half e_ehsize;\r
+ Elf64_Half e_phentsize;\r
+ Elf64_Half e_phnum;\r
+ Elf64_Half e_shentsize;\r
+ Elf64_Half e_shnum;\r
+ Elf64_Half e_shstrndx;\r
+} Elf64_Ehdr;\r
\r
/**\r
- \name Executable Types\r
- \{\r
-*/\r
-#define ET_NONE 0 //!< NULL Type\r
-#define ET_REL 1 //!< Relocatable (Object)\r
-#define ET_EXEC 2 //!< Executable\r
-#define ET_DYN 3 //!< Dynamic Library\r
-#define ET_CORE 4 //!< Core?\r
-#define ET_LOPROC 0xFF00 //!< Low Impl Defined\r
-#define ET_HIPROC 0xFFFF //!< High Impl Defined\r
-//! \}\r
+ * \brief Executable Types\r
+ */\r
+enum eElf32_ExecTypes\r
+{\r
+ ET_NONE = 0, //!< NULL Type\r
+ ET_REL = 1, //!< Relocatable (Object)\r
+ ET_EXEC = 2, //!< Executable\r
+ ET_DYN = 3, //!< Dynamic Library\r
+ ET_CORE = 4, //!< Core?\r
+ ET_LOPROC = 0xFF00, //!< Low Impl Defined\r
+ ET_HIPROC = 0xFFFF //!< High Impl Defined\r
+};\r
\r
/**\r
\name Section IDs\r
*/\r
#define SHN_UNDEF 0 //!< Undefined Section\r
#define SHN_LORESERVE 0xFF00 //!< Low Reserved\r
-#define SHN_LOPROC 0xFF00 //!< Low Impl Defined\r
-#define SHN_HIPROC 0xFF1F //!< High Impl Defined\r
-#define SHN_ABS 0xFFF1 //!< Absolute Address (Base: 0, Size: -1)\r
-#define SHN_COMMON 0xFFF2 //!< Common\r
+#define SHN_LOPROC 0xFF00 //!< Low Impl Defined\r
+#define SHN_HIPROC 0xFF1F //!< High Impl Defined\r
+#define SHN_ABS 0xFFF1 //!< Absolute Address (Base: 0, Size: -1)\r
+#define SHN_COMMON 0xFFF2 //!< Common\r
#define SHN_HIRESERVE 0xFFFF //!< High Reserved\r
//! \}\r
\r
Uint32 info;\r
Uint32 addralign;\r
Uint32 entsize;\r
-}; //sizeof = 40\r
+} __attribute__ ((packed)); //sizeof = 40\r
+\r
+typedef struct\r
+{\r
+ Elf64_Word sh_name;\r
+ Elf64_Word sh_type;\r
+ Elf64_Xword sh_flags;\r
+ Elf64_Addr sh_addr;\r
+ Elf64_Off sh_offset;\r
+ Elf64_Xword sh_size;\r
+ Elf64_Word sh_link;\r
+ Elf64_Word sh_info;\r
+ Elf64_Xword sh_addralign;\r
+ Elf64_Xword sh_entsize;\r
+} Elf64_Shdr;\r
\r
struct elf_sym_s {\r
union {\r
Uint8 info;\r
Uint8 other;\r
Uint16 shndx;\r
-};\r
+} __attribute__ ((packed));\r
#define STN_UNDEF 0 // Undefined Symbol\r
\r
enum {\r
\r
struct sElf32_Phdr {\r
Uint32 Type;\r
- Uint Offset;\r
- Uint VAddr;\r
- Uint PAddr;\r
+ Uint32 Offset;\r
+ Uint32 VAddr;\r
+ Uint32 PAddr;\r
Uint32 FileSize;\r
Uint32 MemSize;\r
Uint32 Flags;\r
Uint32 Align;\r
-};\r
+} __attribute__ ((packed));\r
+\r
+typedef struct\r
+{\r
+ Elf64_Word p_type;\r
+ Elf64_Word p_flags;\r
+ Elf64_Off p_offset;\r
+ Elf64_Addr p_vaddr;\r
+ Elf64_Addr p_paddr;\r
+ Elf64_Xword p_filesz;\r
+ Elf64_Xword p_memsz;\r
+ Elf64_Xword p_align;\r
+} Elf64_Phdr;\r
+\r
+#define PF_X 1\r
+#define PF_W 2\r
+#define PF_R 4\r
\r
struct elf32_rel_s {\r
Uint32 r_offset;\r
Uint32 r_info;\r
-};\r
+} __attribute__ ((packed));\r
\r
struct elf32_rela_s {\r
Uint32 r_offset;\r
Uint32 r_info;\r
Sint32 r_addend;\r
-};\r
+} __attribute__ ((packed));\r
\r
enum {\r
R_386_NONE = 0, // none\r
struct elf32_dyn_s {\r
Uint32 d_tag;\r
Uint32 d_val; //Also d_ptr\r
-};\r
+} __attribute__ ((packed));\r
\r
enum {\r
DT_NULL, //!< Marks End of list\r