Changeset 227 for trunk/kernel/libk/elf.h
- Timestamp:
- Jul 18, 2017, 12:32:31 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/elf.h
r204 r227 28 28 */ 29 29 30 /* Type for a 16-bit quantity. */ 30 #define EI_NIDENT (16) 31 32 /* 32bit version */ 31 33 typedef uint16_t Elf32_Half; 32 33 /* Types for signed and unsigned 32-bit quantities. */34 34 typedef uint32_t Elf32_Word; 35 typedef int32_t Elf32_Sword; 36 37 /* Type of addresses. */ 35 typedef int32_t Elf32_Sword; 38 36 typedef uint32_t Elf32_Addr; 39 40 /* Type of file offsets. */41 37 typedef uint32_t Elf32_Off; 42 38 43 /* Type for section indices, which are 16-bit quantities. */ 44 typedef uint16_t Elf32_Section; 45 46 /* Type for version symbol information. */ 47 typedef Elf32_Half Elf32_Versym; 48 49 /************************************************************************************* 50 * This structure defines the ELF file header (first bytes in the file) 51 *************************************************************************************/ 52 53 #define EI_NIDENT (16) 54 55 typedef struct 56 { 57 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ 39 /* 64bit version */ 40 typedef uint16_t Elf64_Half; 41 typedef uint32_t Elf64_Word; 42 typedef int32_t Elf64_Sword; 43 typedef uint64_t Elf64_Addr; 44 typedef uint64_t Elf64_Off; 45 46 /* ELF header - 32bit version. */ 47 typedef struct 48 { 49 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ 58 50 Elf32_Half e_type; /* Object file type */ 59 51 Elf32_Half e_machine; /* Architecture */ 60 52 Elf32_Word e_version; /* Object file version */ 61 Elf32_Addr 62 Elf32_Off 63 Elf32_Off 53 Elf32_Addr e_entry; /* Entry point virtual address */ 54 Elf32_Off e_phoff; /* Program header table file offset */ 55 Elf32_Off e_shoff; /* Section header table file offset */ 64 56 Elf32_Word e_flags; /* Processor-specific flags */ 65 57 Elf32_Half e_ehsize; /* ELF header size in bytes */ … … 71 63 } 72 64 Elf32_Ehdr; 65 66 /* ELF header - 64bit version. */ 67 typedef struct 68 { 69 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ 70 Elf64_Half e_type; /* Object file type */ 71 Elf64_Half e_machine; /* Architecture */ 72 Elf64_Word e_version; /* Object file version */ 73 Elf64_Addr e_entry; /* Entry point virtual address */ 74 Elf64_Off e_phoff; /* Program header table file offset */ 75 Elf64_Off e_shoff; /* Section header table file offset */ 76 Elf64_Word e_flags; /* Processor-specific flags */ 77 Elf64_Half e_ehsize; /* ELF header size in bytes */ 78 Elf64_Half e_phentsize; /* Program header table entry size */ 79 Elf64_Half e_phnum; /* Program header table entry count */ 80 Elf64_Half e_shentsize; /* Section header table entry size */ 81 Elf64_Half e_shnum; /* Section header table entry count */ 82 Elf64_Half e_shstrndx; /* Section header string table index */ 83 } 84 Elf64_Ehdr; 73 85 74 86 /* … … 132 144 #define EV_NUM 2 133 145 134 /* Program segment header. */ 135 136 typedef struct 137 { 138 Elf32_Word p_type; /* Segment type */ 139 Elf32_Off p_offset; /* Segment file offset */ 140 Elf32_Addr p_vaddr; /* Segment virtual address */ 141 Elf32_Addr p_paddr; /* Segment physical address */ 142 Elf32_Word p_filesz; /* Segment size in file */ 143 Elf32_Word p_memsz; /* Segment size in memory */ 144 Elf32_Word p_flags; /* Segment flags */ 145 Elf32_Word p_align; /* Segment alignment */ 146 /* Program segment header - 32bit version. */ 147 typedef struct 148 { 149 Elf32_Word p_type; /* Segment type */ 150 Elf32_Off p_offset; /* Segment file offset */ 151 Elf32_Addr p_vaddr; /* Segment virtual address */ 152 Elf32_Addr p_paddr; /* Segment physical address */ 153 Elf32_Word p_filesz; /* Segment size in file */ 154 Elf32_Word p_memsz; /* Segment size in memory */ 155 Elf32_Word p_flags; /* Segment flags */ 156 Elf32_Word p_align; /* Segment alignment */ 146 157 } 147 158 Elf32_Phdr; 159 160 /* Program segment header - 64bit version. */ 161 typedef struct 162 { 163 Elf64_Word p_type; /* Segment type */ 164 Elf64_Word p_flags; /* Segment flags */ 165 Elf64_Off p_offset; /* Segment file offset */ 166 Elf64_Addr p_vaddr; /* Segment virtual address */ 167 Elf64_Addr p_paddr; /* Segment physical address */ 168 Elf64_Word p_filesz; /* Segment size in file */ 169 Elf64_Word p_memsz; /* Segment size in memory */ 170 Elf64_Word p_align; /* Segment alignment */ 171 } 172 Elf64_Phdr; 148 173 149 174 /* Legal values for p_type (segment type). */ … … 176 201 #define PF_MASKPROC 0xf0000000 /* Processor-specific */ 177 202 203 #if defined(HAL_32BIT) 204 #define Elf_Half Elf32_Half 205 #define Elf_Word Elf32_Word 206 #define Elf_Sword Elf32_Sword 207 #define Elf_Addr Elf32_Addr 208 #define Elf_Off Elf32_Off 209 #define Elf_Ehdr Elf32_Ehdr 210 #define Elf_Phdr Elf32_Phdr 211 #elif defined (HAL_64BIT) 212 #define Elf_Half Elf64_Half 213 #define Elf_Word Elf64_Word 214 #define Elf_Sword Elf64_Sword 215 #define Elf_Addr Elf64_Addr 216 #define Elf_Off Elf64_Off 217 #define Elf_Ehdr Elf64_Ehdr 218 #define Elf_Phdr Elf64_Phdr 219 #else 220 #error "Must define HAL_64BIT/HAL_32BIT" 221 #endif 178 222 179 223 /****************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.