From e37280b0e5ad5e836db2909e7726b58a66ca1a04 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 6 Jan 2023 17:34:24 +0100 Subject: [PATCH] ELFLoader: Set both the read-write and execute flags if the section has both Not good for W^X, but the compiler decides to squash everything into a single program header :( --- kernel/src/ELF.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/src/ELF.cpp b/kernel/src/ELF.cpp index df28d389..1af55e15 100644 --- a/kernel/src/ELF.cpp +++ b/kernel/src/ELF.cpp @@ -96,8 +96,7 @@ namespace ELFLoader int flags = MMU::User | MMU::NoExecute; if (can_write_segment(program_header.p_flags)) flags |= MMU::ReadWrite; - else if (can_execute_segment(program_header.p_flags)) - flags &= ~MMU::NoExecute; + if (can_execute_segment(program_header.p_flags)) flags &= ~MMU::NoExecute; // Allocate physical memory for the segment TRY(MemoryManager::alloc_at(