[e16e8f2] | 1 | /* |
---|
| 2 | * sys/elf64.h |
---|
| 3 | */ |
---|
| 4 | |
---|
| 5 | #ifndef _SYS_ELF64_H |
---|
| 6 | #define _SYS_ELF64_H |
---|
| 7 | |
---|
| 8 | #include <sys/elfcommon.h> |
---|
| 9 | |
---|
| 10 | /* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */ |
---|
| 11 | typedef uint16_t Elf64_Half; |
---|
| 12 | typedef int16_t Elf64_SHalf; |
---|
| 13 | typedef uint32_t Elf64_Word; |
---|
| 14 | typedef int32_t Elf64_Sword; |
---|
| 15 | typedef uint64_t Elf64_Xword; |
---|
| 16 | typedef int64_t Elf64_Sxword; |
---|
| 17 | |
---|
| 18 | typedef uint64_t Elf64_Off; |
---|
| 19 | typedef uint64_t Elf64_Addr; |
---|
| 20 | typedef uint16_t Elf64_Section; |
---|
| 21 | |
---|
| 22 | /* Dynamic header */ |
---|
| 23 | |
---|
| 24 | typedef struct elf64_dyn { |
---|
| 25 | Elf64_Sxword d_tag; |
---|
| 26 | union { |
---|
| 27 | Elf64_Xword d_val; |
---|
| 28 | Elf64_Addr d_ptr; |
---|
| 29 | } d_un; |
---|
| 30 | } Elf64_Dyn; |
---|
| 31 | |
---|
| 32 | /* Relocations */ |
---|
| 33 | |
---|
| 34 | #define ELF64_R_SYM(x) ((x) >> 32) |
---|
| 35 | #define ELF64_R_TYPE(x) ((x) & 0xffffffff) |
---|
| 36 | |
---|
| 37 | typedef struct elf64_rel { |
---|
| 38 | Elf64_Addr r_offset; |
---|
| 39 | Elf64_Xword r_info; |
---|
| 40 | } Elf64_Rel; |
---|
| 41 | |
---|
| 42 | typedef struct elf64_rela { |
---|
| 43 | Elf64_Addr r_offset; |
---|
| 44 | Elf64_Xword r_info; |
---|
| 45 | Elf64_Sxword r_addend; |
---|
| 46 | } Elf64_Rela; |
---|
| 47 | |
---|
| 48 | /* Symbol */ |
---|
| 49 | |
---|
| 50 | typedef struct elf64_sym { |
---|
| 51 | Elf64_Word st_name; |
---|
| 52 | unsigned char st_info; |
---|
| 53 | unsigned char st_other; |
---|
| 54 | Elf64_Half st_shndx; |
---|
| 55 | Elf64_Addr st_value; |
---|
| 56 | Elf64_Xword st_size; |
---|
| 57 | } Elf64_Sym; |
---|
| 58 | |
---|
| 59 | /* Main file header */ |
---|
| 60 | |
---|
| 61 | typedef struct elf64_hdr { |
---|
| 62 | unsigned char e_ident[EI_NIDENT]; |
---|
| 63 | Elf64_Half e_type; |
---|
| 64 | Elf64_Half e_machine; |
---|
| 65 | Elf64_Word e_version; |
---|
| 66 | Elf64_Addr e_entry; |
---|
| 67 | Elf64_Off e_phoff; |
---|
| 68 | Elf64_Off e_shoff; |
---|
| 69 | Elf64_Word e_flags; |
---|
| 70 | Elf64_Half e_ehsize; |
---|
| 71 | Elf64_Half e_phentsize; |
---|
| 72 | Elf64_Half e_phnum; |
---|
| 73 | Elf64_Half e_shentsize; |
---|
| 74 | Elf64_Half e_shnum; |
---|
| 75 | Elf64_Half e_shstrndx; |
---|
| 76 | } Elf64_Ehdr; |
---|
| 77 | |
---|
| 78 | /* Program header */ |
---|
| 79 | |
---|
| 80 | typedef struct elf64_phdr { |
---|
| 81 | Elf64_Word p_type; |
---|
| 82 | Elf64_Word p_flags; |
---|
| 83 | Elf64_Off p_offset; |
---|
| 84 | Elf64_Addr p_vaddr; |
---|
| 85 | Elf64_Addr p_paddr; |
---|
| 86 | Elf64_Xword p_filesz; |
---|
| 87 | Elf64_Xword p_memsz; |
---|
| 88 | Elf64_Xword p_align; |
---|
| 89 | } Elf64_Phdr; |
---|
| 90 | |
---|
| 91 | /* Section header */ |
---|
| 92 | |
---|
| 93 | typedef struct elf64_shdr { |
---|
| 94 | Elf64_Word sh_name; |
---|
| 95 | Elf64_Word sh_type; |
---|
| 96 | Elf64_Xword sh_flags; |
---|
| 97 | Elf64_Addr sh_addr; |
---|
| 98 | Elf64_Off sh_offset; |
---|
| 99 | Elf64_Xword sh_size; |
---|
| 100 | Elf64_Word sh_link; |
---|
| 101 | Elf64_Word sh_info; |
---|
| 102 | Elf64_Xword sh_addralign; |
---|
| 103 | Elf64_Xword sh_entsize; |
---|
| 104 | } Elf64_Shdr; |
---|
| 105 | |
---|
| 106 | /* Note header */ |
---|
| 107 | typedef struct elf64_note { |
---|
| 108 | Elf64_Word n_namesz; /* Name size */ |
---|
| 109 | Elf64_Word n_descsz; /* Content size */ |
---|
| 110 | Elf64_Word n_type; /* Content type */ |
---|
| 111 | } Elf64_Nhdr; |
---|
| 112 | |
---|
| 113 | #endif /* _SYS_ELF64_H */ |
---|