X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Fld-acess.so_src%2Felf32.h;h=40c801c92a1b269c8becc87dd3821a6a066c0a45;hb=ca9a575116285753b48fd8e0ae6dcdbf8a4af5b1;hp=983917bdd84b5ced6f466a8043514cf3281ff7ae;hpb=9867382061f9035d65e118d95fa819c0e615f353;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/ld-acess.so_src/elf32.h b/Usermode/Libraries/ld-acess.so_src/elf32.h index 983917bd..40c801c9 100644 --- a/Usermode/Libraries/ld-acess.so_src/elf32.h +++ b/Usermode/Libraries/ld-acess.so_src/elf32.h @@ -6,27 +6,40 @@ #ifndef _ELF32_H #define _ELF32_H +#include + +typedef uint16_t Elf32_Half; +typedef uint32_t Elf32_Addr; +typedef uint32_t Elf32_Off; +typedef uint32_t Elf32_Word; +typedef uint32_t Elf32_Xword; // < not strictly correct... but meh +typedef int32_t Elf32_Sword; + #define ELFCLASS32 1 +#define EM_NONE 0 +#define EM_386 3 +#define EM_ARM 40 + /** \struct elf_header_s \brief ELF File Header */ struct sElf32_Ehdr { - Uint8 e_ident[16]; //!< Identifier Bytes - Uint16 filetype; //!< File Type - Uint16 machine; //!< Machine / Arch - Uint32 version; //!< Version (File?) - Uint32 entrypoint; //!< Entry Point - Uint32 phoff; //!< Program Header Offset - Uint32 shoff; //!< Section Header Offset - Uint32 flags; //!< Flags - Uint16 headersize; //!< Header Size - Uint16 phentsize; //!< Program Header Entry Size - Uint16 phentcount; //!< Program Header Entry Count - Uint16 shentsize; //!< Section Header Entry Size - Uint16 shentcount; //!< Section Header Entry Count - Uint16 shstrindex; //!< Section Header String Table Index + uint8_t e_ident[16]; //!< Identifier Bytes + Elf32_Half e_filetype; //!< File Type + Elf32_Half e_machine; //!< Machine / Arch + Elf32_Word e_version; //!< Version (File?) + Elf32_Addr e_entry; //!< Entry Point + Elf32_Off e_phoff; //!< Program Header Offset + Elf32_Word e_shoff; //!< Section Header Offset + Elf32_Word e_flags; //!< Flags + Elf32_Half e_headersize; //!< Header Size + Elf32_Half e_phentsize; //!< Program Header Entry Size + Elf32_Half e_phnum; //!< Program Header Entry Count + Elf32_Half e_shentsize; //!< Section Header Entry Size + Elf32_Half e_shentcount; //!< Section Header Entry Count + Elf32_Half e_shstrindex; //!< Section Header String Table Index }; /** @@ -79,6 +92,7 @@ enum eElfSectionTypes { SHT_HIUSER = 0xffffffff }; +#if 0 #define SHF_WRITE 0x1 #define SHF_ALLOC 0x2 #define SHF_EXECINSTR 0x4 @@ -96,17 +110,27 @@ struct sElf32_Shent { Uint32 addralign; Uint32 entsize; }; //sizeof = 40 +#endif struct elf_sym_s { - Uint32 nameOfs; - Uint32 value; //Address - Uint32 size; - Uint8 info; - Uint8 other; - Uint16 shndx; + Elf32_Word st_name; + Elf32_Addr st_value; //Address + Elf32_Word st_size; + uint8_t st_info; + uint8_t st_other; + Elf32_Half st_shndx; }; #define STN_UNDEF 0 // Undefined Symbol +#define ELF32_ST_BIND(i) ((i)>>4) +#define ELF32_ST_TYPE(i) ((i)&0xF) + +enum { + STB_LOCAL, + STB_GLOBAL, + STB_WEAK, +}; + enum { PT_NULL, //0 PT_LOAD, //1 @@ -119,26 +143,30 @@ enum { PT_HIPROC = 0x7fffffff }; +#define PF_X 1 +#define PF_W 2 +#define PF_R 4 + struct sElf32_Phdr { - Uint32 Type; - Uint Offset; - Uint VAddr; - Uint PAddr; - Uint32 FileSize; - Uint32 MemSize; - Uint32 Flags; - Uint32 Align; + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; }; struct elf32_rel_s { - Uint32 r_offset; - Uint32 r_info; + Elf32_Addr r_offset; + Elf32_Word r_info; }; struct elf32_rela_s { - Uint32 r_offset; - Uint32 r_info; - Sint32 r_addend; + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; }; enum { @@ -156,13 +184,44 @@ enum { R_386_LAST // none }; +// NOTES: +// 'T' means the thumb bit +// 'B(S)' Origin of a symbol +enum { + R_ARM_NONE, // 0 No action + R_ARM_PC24, // 1 ((S + A) | T) - P + R_ARM_ABS32, // 2 (S + A) | T + R_ARM_REL32, // 3 ((S + A) | T) - P + R_ARM_LDR_PC_G0, // 4 S + A - P + R_ARM_ABS16, // 5 S + A + R_ARM_ABS12, // 6 S + A + R_ARM_THM_ABS5, // 7 S + A + R_ARM_ABS8, // 8 S + A + R_ARM_SBREL32, // 9 ((S + A) | T) - B(S) + R_ARM_THM_CALL, // 10 ((S + A) | T) - P + R_ARM_THM_PC8, // 11 S + A - Pa, + R_ARM_BREL_ADJ, // 12 ΔB(S) + A + R_ARM_TLS_DESC, // 13 -- + R_ARM_THM_SWI8, // 14 (Reserved) + R_ARM_XPC25, // 15 (Reserved) + R_ARM_THM_XPC22, // 16 (Reserved) + R_ARM_TLS_DTPMOD32, // 17 Module[S] + R_ARM_TLS_DTPOFF32, // 18 S + A - TLS + R_ARM_TLS_TPOFF32, // 19 S + A - tp + R_ARM_COPY, // 20 Misc + R_ARM_GLOB_DAT, // 21 (S + A) | T + R_ARM_JUMP_SLOT, // 22 (S + A) | T + R_ARM_RELATIVE, // 23 B(S) + A (extra?) + // ... More defined (IHI0044) +}; + #define ELF32_R_SYM(i) ((i)>>8) // Takes an info value and returns a symbol index #define ELF32_R_TYPE(i) ((i)&0xFF) // Takes an info value and returns a type #define ELF32_R_INFO(s,t) (((s)<<8)+((t)&0xFF)) // Takes a type and symbol index and returns an info value struct elf32_dyn_s { - Uint16 d_tag; - Uint32 d_val; //Also d_ptr + Elf32_Half d_tag; + Elf32_Word d_val; //Also d_ptr }; enum {