diff options
author | Marvin Borner | 2021-04-03 18:33:26 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-03 18:33:26 +0200 |
commit | 0162d9cafc2c9b14fe6f319d1fbca74b26bd0b3d (patch) | |
tree | ba7bf845e3e4721e5f1645a8c5a261b68ad3d89d /kernel/inc | |
parent | bd1ad65704d44e3e06a587a890e8087bfd9abe3b (diff) |
Added readonly remap of readonly elf sections
Diffstat (limited to 'kernel/inc')
-rw-r--r-- | kernel/inc/load.h | 82 | ||||
-rw-r--r-- | kernel/inc/mm.h | 1 |
2 files changed, 70 insertions, 13 deletions
diff --git a/kernel/inc/load.h b/kernel/inc/load.h index 365da79..af59cce 100644 --- a/kernel/inc/load.h +++ b/kernel/inc/load.h @@ -41,6 +41,7 @@ #define ELF_ETYPE_EXEC 2 #define ELF_ETYPE_DYN 3 #define ELF_ETYPE_CORE 4 +#define ELF_ETYPE_NUM 5 #define ELF_MACHINE_NONE 0 #define ELF_MACHINE_SPARC 2 @@ -49,19 +50,18 @@ #define ELF_MACHINE_SPARCV9 43 #define ELF_MACHINE_AMD64 62 -#define ELF_FLAG_SPARC_EXT_MASK 0xffff00 -#define ELF_FLAG_SPARC_32PLUS 0x000100 -#define ELF_FLAG_SPARC_SUN_US1 0x000200 -#define ELF_FLAG_SPARC_HAL_R1 0x000400 -#define ELF_FLAG_SPARC_SUN_US3 0x000800 -#define ELF_FLAG_SPARCV9_MM 0x3 -#define ELF_FLAG_SPARCV9_TSO 0x0 -#define ELF_FLAG_SPARCV9_PSO 0x1 -#define ELF_FLAG_SPARCV9_RMO 0x2 +#define ELF_PROGRAM_TYPE_NULL 0 +#define ELF_PROGRAM_TYPE_LOAD 1 +#define ELF_PROGRAM_TYPE_DYNAMIC 2 +#define ELF_PROGRAM_TYPE_INTERP 3 +#define ELF_PROGRAM_TYPE_NOTE 4 +#define ELF_PROGRAM_TYPE_SHLIB 5 +#define ELF_PROGRAM_TYPE_PHDR 6 +#define ELF_PROGRAM_TYPE_TLS 7 -#define ELF_PROGRAM_X 0x1 -#define ELF_PROGRAM_W 0x2 -#define ELF_PROGRAM_R 0x4 +#define ELF_PROGRAM_FLAG_X 0x1 +#define ELF_PROGRAM_FLAG_W 0x2 +#define ELF_PROGRAM_FLAG_R 0x4 #define ELF_SECTION_TYPE_NULL 0 #define ELF_SECTION_TYPE_PROGBITS 1 @@ -77,6 +77,40 @@ #define ELF_SECTION_TYPE_DYNSYM 11 #define ELF_SECTION_TYPE_COUNT 12 +#define ELF_SECTION_FLAG_WRITE 0x1 +#define ELF_SECTION_FLAG_ALLOC 0x2 +#define ELF_SECTION_FLAG_EXEC 0x3 +#define ELF_SECTION_FLAG_MERGE 0x10 +#define ELF_SECTION_FLAG_STRINGS 0x20 +#define ELF_SECTION_FLAG_INFO_LINK 0x40 +#define ELF_SECTION_FLAG_LINK_ORDER 0x80 +#define ELF_SECTION_FLAG_OS_SPECIAL 0x100 +#define ELF_SECTION_FLAG_GROUP 0x200 +#define ELF_SECTION_FLAG_TLS 0x400 +#define ELF_SECTION_FLAG_COMPRESSED 0x800 + +#define ELF_BSS ".bss" +#define ELF_DATA ".data" +#define ELF_DEBUG ".debug" +#define ELF_DYNAMIC ".dynamic" +#define ELF_DYNSTR ".dynstr" +#define ELF_DYNSYM ".dynsym" +#define ELF_FINI ".fini" +#define ELF_GOT ".got" +#define ELF_HASH ".hash" +#define ELF_INIT ".init" +#define ELF_REL_DATA ".rel.data" +#define ELF_REL_FINI ".rel.fini" +#define ELF_REL_INIT ".rel.init" +#define ELF_REL_DYN ".rel.dyn" +#define ELF_REL_RODATA ".rel.rodata" +#define ELF_REL_TEXT ".rel.text" +#define ELF_RODATA ".rodata" +#define ELF_SHSTRTAB ".shstrtab" +#define ELF_STRTAB ".strtab" +#define ELF_SYMTAB ".symtab" +#define ELF_TEXT ".text" + struct PACKED elf_header { u8 ident[ELF_IDENT_COUNT]; u16 type; @@ -94,7 +128,7 @@ struct PACKED elf_header { u16 shstrndx; }; -struct elf_program { +struct PACKED elf_program { u32 type; u32 offset; u32 vaddr; @@ -105,6 +139,28 @@ struct elf_program { u32 align; }; +struct PACKED elf_section { + u32 name; + u32 type; + u32 flags; + u32 addr; + u32 offset; + u32 size; + u32 link; + u32 info; + u32 addralign; + u32 entsize; +}; + +struct PACKED elf_symbol { + u32 name; + u32 value; + u32 size; + u8 info; + u8 other; + u16 shndx; +}; + res elf_load(const char *path, struct proc *proc) NONNULL; #endif diff --git a/kernel/inc/mm.h b/kernel/inc/mm.h index 7226adb..b7032c8 100644 --- a/kernel/inc/mm.h +++ b/kernel/inc/mm.h @@ -85,6 +85,7 @@ struct page_dir { u8 virtual_present(struct page_dir *dir, u32 vaddr) NONNULL; u32 virtual_to_physical(struct page_dir *dir, u32 vaddr) NONNULL; void virtual_map(struct page_dir *dir, struct memory_range prange, u32 vaddr, u32 flags) NONNULL; +void virtual_remap_readonly(struct page_dir *dir, struct memory_range vrange); struct memory_range virtual_alloc(struct page_dir *dir, struct memory_range physical_range, u32 flags) NONNULL; void virtual_free(struct page_dir *dir, struct memory_range vrange) NONNULL; |