1/* 2 * sys/elf32.h 3 */ 4 5#ifndef _SYS_ELF32_H 6#define _SYS_ELF32_H 7 8#include <sys/elfcommon.h> 9 10/* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */ 11typedef uint16_t Elf32_Half; 12typedef int16_t Elf32_SHalf; 13typedef uint32_t Elf32_Word; 14typedef int32_t Elf32_Sword; 15typedef uint64_t Elf32_Xword; 16typedef int64_t Elf32_Sxword; 17 18typedef uint32_t Elf32_Off; 19typedef uint32_t Elf32_Addr; 20typedef uint16_t Elf32_Section; 21 22/* Dynamic header */ 23 24typedef struct elf32_dyn { 25 Elf32_Sword d_tag; 26 union { 27 Elf32_Sword d_val; 28 Elf32_Addr d_ptr; 29 } d_un; 30} Elf32_Dyn; 31 32/* Relocations */ 33 34#define ELF32_R_SYM(x) ((x) >> 8) 35#define ELF32_R_TYPE(x) ((x) & 0xff) 36 37typedef struct elf32_rel { 38 Elf32_Addr r_offset; 39 Elf32_Word r_info; 40} Elf32_Rel; 41 42typedef struct elf32_rela { 43 Elf32_Addr r_offset; 44 Elf32_Word r_info; 45 Elf32_Sword r_addend; 46} Elf32_Rela; 47 48/* Symbol */ 49 50typedef struct elf32_sym { 51 Elf32_Word st_name; 52 Elf32_Addr st_value; 53 Elf32_Word st_size; 54 unsigned char st_info; 55 unsigned char st_other; 56 Elf32_Half st_shndx; 57} Elf32_Sym; 58 59/* Main file header */ 60 61typedef struct elf32_hdr { 62 unsigned char e_ident[EI_NIDENT]; 63 Elf32_Half e_type; 64 Elf32_Half e_machine; 65 Elf32_Word e_version; 66 Elf32_Addr e_entry; 67 Elf32_Off e_phoff; 68 Elf32_Off e_shoff; 69 Elf32_Word e_flags; 70 Elf32_Half e_ehsize; 71 Elf32_Half e_phentsize; 72 Elf32_Half e_phnum; 73 Elf32_Half e_shentsize; 74 Elf32_Half e_shnum; 75 Elf32_Half e_shstrndx; 76} Elf32_Ehdr; 77 78/* Program header */ 79 80typedef struct elf32_phdr { 81 Elf32_Word p_type; 82 Elf32_Off p_offset; 83 Elf32_Addr p_vaddr; 84 Elf32_Addr p_paddr; 85 Elf32_Word p_filesz; 86 Elf32_Word p_memsz; 87 Elf32_Word p_flags; 88 Elf32_Word p_align; 89} Elf32_Phdr; 90 91/* Section header */ 92 93typedef struct elf32_shdr { 94 Elf32_Word sh_name; 95 Elf32_Word sh_type; 96 Elf32_Word sh_flags; 97 Elf32_Addr sh_addr; 98 Elf32_Off sh_offset; 99 Elf32_Word sh_size; 100 Elf32_Word sh_link; 101 Elf32_Word sh_info; 102 Elf32_Word sh_addralign; 103 Elf32_Word sh_entsize; 104} Elf32_Shdr; 105 106/* Note header */ 107typedef struct elf32_note { 108 Elf32_Word n_namesz; /* Name size */ 109 Elf32_Word n_descsz; /* Content size */ 110 Elf32_Word n_type; /* Content type */ 111} Elf32_Nhdr; 112 113#endif /* _SYS_ELF32_H */ 114