#ifndef _JOVE_LIB_ELF_H #define _JOVE_LIB_ELF_H 1 #include #define EI_MAG0 0x7F #define EI_MAG1 0x45 #define EI_MAG2 0x4C #define EI_MAG3 0x46 #define EI_CLASS_64 2 #define EI_DATA_LE 1 #define ET_EXEC 0x02 #define EM_x86_64 0x3E struct elf_header { uint8_t e_ident[16]; uint16_t e_type; uint16_t e_machine; uint32_t e_version; uint64_t e_entry; uint64_t e_phoff; uint64_t e_shoff; uint32_t e_flags; uint16_t e_ehsize; uint16_t e_phentsize; uint16_t e_phnum; uint16_t e_shentsize; uint16_t e_shnum; uint16_t e_shstrndx; }; struct elf_phdr { uint32_t p_type; uint32_t p_flags; uint64_t p_offset; uint64_t p_vaddr; uint64_t p_paddr; uint64_t p_filesz; uint64_t p_memsz; uint64_t p_align; }; #define SHT_PROGBITS 1 #define SHT_NOBITS 4 #define SHF_WRITE 0x1 #define SHF_ALLOC 0x2 #define SHF_EXECINSTR 0x4 struct elf_shdr { uint32_t sh_name; uint32_t sh_type; uint64_t sh_flags; uint64_t sh_addr; uint64_t sh_offset; uint64_t sh_size; uint32_t sh_link; uint32_t sh_info; uint64_t sh_addralign; uint64_t sh_entsize; }; #endif