From d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Mon, 11 Mar 2024 21:30:31 -0400 Subject: usermode capable kernel with logging syscall --- arch/x86_64/elf.h | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 arch/x86_64/elf.h (limited to 'arch/x86_64/elf.h') diff --git a/arch/x86_64/elf.h b/arch/x86_64/elf.h new file mode 100644 index 0000000..ebcd228 --- /dev/null +++ b/arch/x86_64/elf.h @@ -0,0 +1,78 @@ +#ifndef JOVE_ARCH_x86_64_ELF_H +#define JOVE_ARCH_x86_64_ELF_H 1 + +#include + +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_OSABI 7 +#define EI_ABIVERSION 8 +#define EI_PAD 9 + +#define E_IDENT_MAG0 0x7F +#define E_IDENT_MAG1 'E' +#define E_IDENT_MAG2 'L' +#define E_IDENT_MAG3 'F' + +#define E_IDENT_CLASS32 1 +#define E_IDENT_CLASS64 2 + +#define ET_EXEC 0x02 + +struct ELF_header +{ + uint8_t e_ident[15]; + 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; +}; + +#define PT_NULL 0 +#define PT_LOAD 1 + +#define PF_X 1 +#define PF_W 2 +#define PF_R 4 + +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; +}; + +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 -- cgit v1.2.1