get_symbol_name: handle case where sys/moon.sym is not present in the initial ramdisk

This commit is contained in:
apio 2022-09-24 21:38:36 +02:00
parent f640e3d248
commit 57b330e907

View File

@ -7,7 +7,7 @@
extern int kernel_start;
extern int kernel_end;
static InitRD::File symbol_map = {"", 0, 0, 0};
static InitRD::File symbol_map = {"", 0, 0, (void*)-1};
static size_t symbol_strlen(const char* symbol)
{
@ -19,7 +19,8 @@ static size_t symbol_strlen(const char* symbol)
void get_symbol_name(uintptr_t address, char* buffer)
{
if (!symbol_map.addr) { symbol_map = InitRD::open("sys/moon.sym"); }
if (symbol_map.addr == (void*)-1) { symbol_map = InitRD::open("sys/moon.sym"); }
if (!symbol_map.addr) { strncpy(buffer, "(no symbols loaded)", 20); }
while (address >= (uintptr_t)&kernel_start && address <= (uintptr_t)&kernel_end)
{
char addr_as_str[60];