Skip to content

Commit

Permalink
dlfcn: improve symbol error messages to show the DSO filename
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Dec 16, 2024
1 parent 559177d commit 65eb36b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/dlfcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static dso_sym_t *search_global_sym(const char *name)
return search_module_next_sym(__dl_list_head, name);
}

static void resolve_syms(dso_module_t *module)
static void resolve_syms(dso_module_t *module, const char *filename)
{
for(uint32_t i=0; i<module->num_syms; i++) {
if(i >= 1 && i < module->num_import_syms+1) {
Expand All @@ -229,10 +229,10 @@ static void resolve_syms(dso_module_t *module)
//Output symbol find error with demangled name if one exists
char *demangle_name = __dl_demangle_func(module->syms[i].name);
if(demangle_name) {
assertf(0, "Failed to find symbol %s(%s)", module->syms[i].name, demangle_name);
assertf(0, "Failed to find symbol %s(%s) needed by %s", module->syms[i].name, demangle_name, filename);
}
}
assertf(0, "Failed to find symbol %s", module->syms[i].name);
assertf(0, "Failed to find symbol %s needed by %s", module->syms[i].name, filename);
}
module->syms[i].value = found_sym->value;
} else {
Expand Down Expand Up @@ -350,7 +350,7 @@ static void relocate_module(dso_module_t *module)
}
}

static void link_module(dso_module_t *module)
static void link_module(dso_module_t *module, const char *filename)
{
//Relocate module pointers
module->syms = PTR_DECODE(module, module->syms);
Expand All @@ -359,7 +359,7 @@ static void link_module(dso_module_t *module)
module->src_elf = PTR_DECODE(module, module->src_elf);
module->filename = PTR_DECODE(module, module->filename);
fixup_sym_names(module->syms, (uint8_t *)module, module->num_syms);
resolve_syms(module);
resolve_syms(module, filename);
relocate_module(module);
flush_module(module);
}
Expand Down Expand Up @@ -419,7 +419,7 @@ void *dlopen(const char *filename, int mode)
} else {
handle = asset_load(filename, NULL);
assertf(handle->magic == DSO_MAGIC, "Invalid DSO file");
link_module(handle);
link_module(handle, filename);
handle->mode = mode;
if(strncmp(filename, "rom:/", 5) == 0) {
sprintf(handle->filename, "%s.sym", filename+5);
Expand Down

0 comments on commit 65eb36b

Please sign in to comment.