1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

LibC+LibELF: Implement more fully-features dlfcn functionality

This implements more of the dlfcn functionality. Most notably:

* It's now possible to dlopen() libraries which were already
  loaded at program startup time. This does not cause those
  libraries to be loaded twice.
* Errors are reported via dlerror() rather than by crashing
  the program.
* Calls to the dl*() functions are thread-safe.
This commit is contained in:
Gunnar Beutner 2021-04-24 20:39:58 +02:00 committed by Andreas Kling
parent 549d9bd3ea
commit f40ee1b03f
12 changed files with 371 additions and 200 deletions

View file

@ -36,6 +36,7 @@ DynamicObject::DynamicObject(const String& filename, VirtualAddress base_address
DynamicObject::~DynamicObject()
{
// TODO: unmap the object
}
void DynamicObject::dump() const
@ -482,4 +483,15 @@ u32 DynamicObject::HashSymbol::sysv_hash() const
m_sysv_hash = compute_sysv_hash(m_name);
return m_sysv_hash.value();
}
void* DynamicObject::symbol_for_name(const StringView& name)
{
auto result = hash_section().lookup_symbol(name);
if (!result.has_value())
return nullptr;
auto symbol = result.value();
if (symbol.is_undefined())
return nullptr;
return base_address().offset(symbol.value()).as_ptr();
}
} // end namespace ELF