sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

elf.h (2150B)


      1 #ifndef ELF_H
      2 #define ELF_H
      3 
      4 #include <stdint.h>
      5 
      6 #define EI_DATA      5
      7 #define EI_NIDENT    16
      8 #define SHT_SYMTAB   2
      9 #define SHT_DYNAMIC  6
     10 #define SHT_REL      9
     11 #define SHT_DYNSYM   11
     12 #define SHT_MIPS_REGINFO    0x70000006
     13 #define STN_UNDEF    0
     14 #define STT_OBJECT   1
     15 #define STT_FUNC     2
     16 #define DT_PLTGOT    3
     17 #define DT_MIPS_LOCAL_GOTNO 0x7000000a
     18 #define DT_MIPS_SYMTABNO    0x70000011
     19 #define DT_MIPS_GOTSYM      0x70000013
     20 
     21 #define ELF32_R_SYM(info)  ((info) >> 8)
     22 #define ELF32_R_TYPE(info) ((info) & 0xff)
     23 
     24 #define ELF32_ST_TYPE(info) ((info) & 0xf)
     25 
     26 #define R_MIPS_26    4
     27 #define R_MIPS_HI16  5
     28 #define R_MIPS_LO16  6
     29 
     30 #define SHN_UNDEF 0
     31 #define SHN_COMMON 0xfff2
     32 #define SHN_MIPS_ACOMMON 0xff00
     33 #define SHN_MIPS_TEXT 0xff01
     34 #define SHN_MIPS_DATA 0xff02
     35 
     36 typedef uint32_t Elf32_Addr;
     37 typedef uint32_t Elf32_Off;
     38 
     39 typedef struct {
     40    uint8_t    e_ident[EI_NIDENT];
     41    uint16_t   e_type;
     42    uint16_t   e_machine;
     43    uint32_t   e_version;
     44    Elf32_Addr e_entry;
     45    Elf32_Off  e_phoff;
     46    Elf32_Off  e_shoff;
     47    uint32_t   e_flags;
     48    uint16_t   e_ehsize;
     49    uint16_t   e_phentsize;
     50    uint16_t   e_phnum;
     51    uint16_t   e_shentsize;
     52    uint16_t   e_shnum;
     53    uint16_t   e_shstrndx;
     54 } Elf32_Ehdr;
     55 
     56 typedef struct {
     57    uint32_t   sh_name;
     58    uint32_t   sh_type;
     59    uint32_t   sh_flags;
     60    Elf32_Addr sh_addr;
     61    Elf32_Off  sh_offset;
     62    uint32_t   sh_size;
     63    uint32_t   sh_link;
     64    uint32_t   sh_info;
     65    uint32_t   sh_addralign;
     66    uint32_t   sh_entsize;
     67 } Elf32_Shdr;
     68 
     69 typedef struct {
     70    uint32_t   st_name;
     71    Elf32_Addr st_value;
     72    uint32_t   st_size;
     73    uint8_t    st_info;
     74    uint8_t    st_other;
     75    uint16_t   st_shndx;
     76 } Elf32_Sym;
     77 
     78 typedef struct {
     79    Elf32_Addr r_offset;
     80    uint32_t   r_info;
     81 } Elf32_Rel;
     82 
     83 typedef struct
     84 {
     85    uint32_t ri_gprmask;    /* General registers used.  */
     86    uint32_t ri_cprmask[4]; /* Coprocessor registers used.  */
     87    int32_t  ri_gp_value;   /* $gp register value.  */
     88 } Elf32_RegInfo;
     89 
     90 typedef struct
     91 {
     92    int32_t d_tag;          /* Dynamic entry type */
     93    union {
     94       uint32_t d_val;      /* Integer value */
     95       Elf32_Addr d_ptr;    /* Address value */
     96    } d_un;
     97 } Elf32_Dyn;
     98 
     99 #endif