X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fbin%2Felf.h;h=13b5373f4e2316d2f9dd0df98ca27c00a0b62987;hb=c4af47e284ab94dc5e365b02f7d91e43f7880280;hp=07f5ec195b4a1147009604a798b6afb018229d96;hpb=38e4b28d370c5f9284b285a71518ae2b6bce125c;p=tpg%2Facess2.git diff --git a/Kernel/bin/elf.h b/Kernel/bin/elf.h index 07f5ec19..13b5373f 100644 --- a/Kernel/bin/elf.h +++ b/Kernel/bin/elf.h @@ -1,16 +1,39 @@ /** - Acess v1 - \file bin_elf.h - \brief ELF Exeutable Loader -*/ + * \file elf.h + * \brief ELF Exeutable Loader + */ #ifndef _BIN_ELF_H #define _BIN_ELF_H +typedef Uint16 Elf64_Half; +typedef Uint32 Elf64_Word; +typedef Uint64 Elf64_Addr; +typedef Uint64 Elf64_Off; +typedef Uint64 Elf64_Xword; + +enum e_ident_values +{ + EI_MAG0, + EI_MAG1, + EI_MAG2, + EI_MAG3, + EI_CLASS, + EI_DATA, + EI_VERSION, + EI_OSABI, + EI_ABIVERSION, + EI_PAD, + EI_NIDENT = 16, +}; + +#define ELFCLASS32 1 +#define ELFCLASS64 2 + /** - \struct elf_header_s - \brief ELF File Header -*/ -struct sElf32_Ehdr { + * \brief ELF File Header + */ +struct sElf32_Ehdr +{ union { char ident[16]; //!< Identifier Bytes struct { @@ -35,18 +58,37 @@ struct sElf32_Ehdr { Uint16 shstrindex; //!< Section Header String Table Index } __attribute__ ((packed)); +typedef struct +{ + unsigned char e_ident[16]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; + /** - \name Executable Types - \{ -*/ -#define ET_NONE 0 //!< NULL Type -#define ET_REL 1 //!< Relocatable (Object) -#define ET_EXEC 2 //!< Executable -#define ET_DYN 3 //!< Dynamic Library -#define ET_CORE 4 //!< Core? -#define ET_LOPROC 0xFF00 //!< Low Impl Defined -#define ET_HIPROC 0xFFFF //!< High Impl Defined -//! \} + * \brief Executable Types + */ +enum eElf32_ExecTypes +{ + ET_NONE = 0, //!< NULL Type + ET_REL = 1, //!< Relocatable (Object) + ET_EXEC = 2, //!< Executable + ET_DYN = 3, //!< Dynamic Library + ET_CORE = 4, //!< Core? + ET_LOPROC = 0xFF00, //!< Low Impl Defined + ET_HIPROC = 0xFFFF //!< High Impl Defined +}; /** \name Section IDs @@ -54,10 +96,10 @@ struct sElf32_Ehdr { */ #define SHN_UNDEF 0 //!< Undefined Section #define SHN_LORESERVE 0xFF00 //!< Low Reserved -#define SHN_LOPROC 0xFF00 //!< Low Impl Defined -#define SHN_HIPROC 0xFF1F //!< High Impl Defined -#define SHN_ABS 0xFFF1 //!< Absolute Address (Base: 0, Size: -1) -#define SHN_COMMON 0xFFF2 //!< Common +#define SHN_LOPROC 0xFF00 //!< Low Impl Defined +#define SHN_HIPROC 0xFF1F //!< High Impl Defined +#define SHN_ABS 0xFFF1 //!< Absolute Address (Base: 0, Size: -1) +#define SHN_COMMON 0xFFF2 //!< Common #define SHN_HIRESERVE 0xFFFF //!< High Reserved //! \} @@ -103,6 +145,20 @@ struct sElf32_Shent { Uint32 entsize; } __attribute__ ((packed)); //sizeof = 40 +typedef struct +{ + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; + struct elf_sym_s { union { Uint32 nameOfs; @@ -130,15 +186,31 @@ enum { struct sElf32_Phdr { Uint32 Type; - Uint Offset; - Uint VAddr; - Uint PAddr; + Uint32 Offset; + Uint32 VAddr; + Uint32 PAddr; Uint32 FileSize; Uint32 MemSize; Uint32 Flags; Uint32 Align; } __attribute__ ((packed)); +typedef struct +{ + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr; + +#define PF_X 1 +#define PF_W 2 +#define PF_R 4 + struct elf32_rel_s { Uint32 r_offset; Uint32 r_info;