From 1b5a771a34743a2973a82de5ebdfd22da030b841 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sun, 18 May 2025 13:21:42 +0000 Subject: update linker file and improve section parsing --- .../include/arch/memory/paging/kernel_mapper.hpp | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'arch/x86_64/include') diff --git a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp index 5bf14fb..977b40d 100644 --- a/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp +++ b/arch/x86_64/include/arch/memory/paging/kernel_mapper.hpp @@ -7,6 +7,9 @@ #include "arch/memory/paging/temporary_page.hpp" #include "arch/video/vga/text.hpp" +#include +#include + namespace teachos::arch::memory::paging { /** @@ -142,24 +145,17 @@ namespace teachos::arch::memory::paging entry entry{section.flags}; // Required to be accessible in User Mode: - // - .boot_bss (Contains statically allocated variables) - // - .user_text (Contains the actual user code executed) - // - .user_data (Contains static user variables) - // - .stl_text (Contains code for custom std implementations and standard library code) - if (section.physical_address == 0x102000 /* .boot_bss */ || - section.physical_address == 0x209000 /* .stl_text */) - { - entry.set_user_accessible(); - } + constexpr std::array user_section_bases = { + 0x102000, // .boot_bss (Contains statically allocated variables) + 0x209000, // .stl_text (Contains code for custom std implementations and standard library code) + 0x218000, // .user_text (Contains the actual user code executed) + 0x21E000, // .user_data (Contains static user variables) - // TODO: Can be removed once stl has been completly mapped into stl text - if (section.physical_address == 0x20A000 /* .text */) - { - entry.set_user_accessible(); - } + 0x20A000 // .text (Necessary, because symbols for standard library are placed there) + }; - if (section.physical_address == 0x218000 /* .user_text */ || - section.physical_address == 0x21E000 /* .user_data */) + if (std::find(user_section_bases.begin(), user_section_bases.end(), section.physical_address) != + user_section_bases.end()) { entry.set_user_accessible(); } -- cgit v1.2.3