From ac1455d3ba2339f7674e4444006b028cf8bafe68 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 20 Jul 2021 02:34:02 +0200 Subject: [PATCH] Kernel: Specify protection flags for ELF load headers These are currently unused by the prekernel and ld used the same flags by default - except for the .ksyms section which was marked as read-write. --- Kernel/linker.ld | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Kernel/linker.ld b/Kernel/linker.ld index 18db2e42da..2ec733f082 100644 --- a/Kernel/linker.ld +++ b/Kernel/linker.ld @@ -8,15 +8,19 @@ ENTRY(init) # define KERNEL_BASE 0x2000000000 #endif +#define PF_X 0x1 +#define PF_W 0x2 +#define PF_R 0x4 + KERNEL_VIRTUAL_BASE = KERNEL_BASE; PHDRS { - super_pages PT_LOAD ; - text PT_LOAD ; - data PT_LOAD ; - bss PT_LOAD ; - ksyms PT_LOAD ; + super_pages PT_LOAD FLAGS(PF_R | PF_W) ; + text PT_LOAD FLAGS(PF_R | PF_X) ; + data PT_LOAD FLAGS(PF_R | PF_W) ; + bss PT_LOAD FLAGS(PF_R | PF_W) ; + ksyms PT_LOAD FLAGS(PF_R) ; } SECTIONS