diff options
author | Tom <tomut@yahoo.com> | 2020-08-10 09:44:35 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-10 20:05:18 +0200 |
commit | 08ff25f4efeb3a676d9607b440b12915c94bf060 (patch) | |
tree | 9fb9dc86444806fbec1e518ba8311a17d655c743 /Kernel/init.cpp | |
parent | de5e5429307e62a6e4ae7980d383c749a66b167f (diff) | |
download | serenity-08ff25f4efeb3a676d9607b440b12915c94bf060.zip |
Kernel: Invoke heap constructors separately early on
By having a separate list of constructors for the kernel heap
code, we can properly use constructors without re-running them
after the heap was already initialized. This solves some problems
where values were wiped out because they were overwritten by
running their constructors later in the initialization process.
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r-- | Kernel/init.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 758b1f32db..69db9f9efd 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -76,6 +76,8 @@ // Defined in the linker script typedef void (*ctor_func_t)(); +extern ctor_func_t start_heap_ctors; +extern ctor_func_t end_heap_ctors; extern ctor_func_t start_ctors; extern ctor_func_t end_ctors; @@ -107,6 +109,9 @@ extern "C" [[noreturn]] void init() s_bsp_processor.early_initialize(0); + // Invoke the constructors needed for the kernel heap + for (ctor_func_t* ctor = &start_heap_ctors; ctor < &end_heap_ctors; ctor++) + (*ctor)(); kmalloc_init(); slab_alloc_init(); |