1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibC+LibELF: Implement dladdr()

This implements the dladdr() function which lets the caller look up
the symbol name, symbol address as well as library name and library
base address for an arbitrary address.
This commit is contained in:
Gunnar Beutner 2021-06-06 17:40:11 +02:00 committed by Andreas Kling
parent f82aa87d14
commit 89a38b72b7
5 changed files with 73 additions and 0 deletions

View file

@ -60,3 +60,15 @@ void* dlsym(void* handle, const char* symbol_name)
}
return result.value();
}
int dladdr(void* addr, Dl_info* info)
{
auto result = __dladdr(addr, info);
if (result.is_error()) {
// FIXME: According to the man page glibc does _not_ make the error
// available via dlerror(), however we do. Does this break anything?
store_error(result.error().text);
return 0;
}
return 1;
}