summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/lib/elf.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-04 21:38:16 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-04 21:38:16 -0400
commit69a27cf95a8a8e3bbbd5e3d81a36893bf312cf3e (patch)
tree47ff56106345e43fbb5184071c8fe72987fe62bb /arch/x86_64/lib/elf.h
parent1768abb217f974cf96448ee847453b604800c546 (diff)
downloadjove-kernel-69a27cf95a8a8e3bbbd5e3d81a36893bf312cf3e.tar.gz
jove-kernel-69a27cf95a8a8e3bbbd5e3d81a36893bf312cf3e.tar.bz2
jove-kernel-69a27cf95a8a8e3bbbd5e3d81a36893bf312cf3e.zip
add usermode jump into init
Diffstat (limited to 'arch/x86_64/lib/elf.h')
-rw-r--r--arch/x86_64/lib/elf.h68
1 files changed, 68 insertions, 0 deletions
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 <stdint.h>
+
+#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