diff --git a/kernel/src/Symbols.cpp b/kernel/src/Symbols.cpp index e8f88fd0..94795063 100644 --- a/kernel/src/Symbols.cpp +++ b/kernel/src/Symbols.cpp @@ -3,6 +3,7 @@ #include "arch/MMU.h" #include "boot/bootboot.h" #include "fs/InitRD.h" +#include "lib/Mutex.h" #include #include #include @@ -18,6 +19,7 @@ struct Symbol }; Vector g_symbols; +static Mutex g_lock; extern const u8 kernel_start; extern const u8 kernel_end; @@ -38,6 +40,8 @@ namespace Symbols { Result load() { + ScopedMutexLock lock(g_lock); + const u64 virtual_initrd_address = MMU::translate_physical_address(bootboot.initrd_ptr); TarStream stream; @@ -80,14 +84,11 @@ namespace Symbols if (address < (u64)&kernel_start) return StringView {}; if (address >= (u64)&kernel_end) return StringView {}; + ScopedMutexLock lock(g_lock); + for (isize i = (isize)g_symbols.size() - 1; i >= 0; i--) { - if (g_symbols[i].address < address) - { - usize index = i + 1; - if (index == g_symbols.size()) return StringView {}; - return StringView { g_symbols[index].symbol }; - } + if (g_symbols[i].address < address) { return StringView { g_symbols[i].symbol }; } } return StringView {};