From 69a27cf95a8a8e3bbbd5e3d81a36893bf312cf3e Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Fri, 4 Sep 2026 21:38:16 -0400 Subject: add usermode jump into init --- arch/x86_64/lib/elf.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 arch/x86_64/lib/elf.h (limited to 'arch/x86_64/lib') diff --git a/arch/x86_64/lib/elf.h b/arch/x86_64/lib/elf.h new file mode 100644 index 0000000..fae2255 --- /dev/null +++ b/arch/x86_64/lib/elf.h @@ -0,0 +1,68 @@ +#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 -- cgit v1.2.3