1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:38:11 +00:00

Kernel: Merge split function and data sections into one during linking

Also add an assertion to make sure the safemem sections are never
discarded by the linker.
This commit is contained in:
Owen Smith 2021-02-09 22:49:02 +00:00 committed by Andreas Kling
parent 9e68752264
commit c2de22a635
2 changed files with 14 additions and 6 deletions

View file

@ -82,6 +82,11 @@ extern ctor_func_t end_ctors;
extern u32 __stack_chk_guard;
u32 __stack_chk_guard;
extern "C" u8* start_of_safemem_text;
extern "C" u8* end_of_safemem_text;
extern "C" u8* start_of_safemem_atomic_text;
extern "C" u8* end_of_safemem_atomic_text;
multiboot_module_entry_t multiboot_copy_boot_modules_array[16];
size_t multiboot_copy_boot_modules_count;
@ -132,6 +137,10 @@ extern "C" [[noreturn]] void init()
CommandLine::initialize();
MemoryManager::initialize(0);
// Ensure that the safemem sections are not empty. This could happen if the linker accidentally discards the sections.
ASSERT(&start_of_safemem_text != &end_of_safemem_text);
ASSERT(&start_of_safemem_atomic_text != &end_of_safemem_atomic_text);
// Invoke all static global constructors in the kernel.
// Note that we want to do this as early as possible.
for (ctor_func_t* ctor = &start_ctors; ctor < &end_ctors; ctor++)