mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibELF: Split the DynamicLoader's loading mechanism into two steps
load_from_image() becomes map() and link(). This allows us to map an object before mapping its dependencies. This solves an issue where fixed-position executables (like GCC) would clash with the ASLR placement of their own shared libraries.
This commit is contained in:
parent
36525c0572
commit
e313323317
4 changed files with 19 additions and 13 deletions
|
@ -181,6 +181,10 @@ static void load_elf(const String& name)
|
|||
{
|
||||
dbgln<DYNAMIC_LOAD_DEBUG>("load_elf: {}", name);
|
||||
auto loader = g_loaders.get(name).value();
|
||||
|
||||
auto dynamic_object = loader->map();
|
||||
ASSERT(dynamic_object);
|
||||
|
||||
for (const auto& needed_name : get_dependencies(name)) {
|
||||
dbgln<DYNAMIC_LOAD_DEBUG>("needed library: {}", needed_name);
|
||||
String library_name = get_library_name(needed_name);
|
||||
|
@ -189,8 +193,8 @@ static void load_elf(const String& name)
|
|||
}
|
||||
}
|
||||
|
||||
auto dynamic_object = loader->load_from_image(RTLD_GLOBAL | RTLD_LAZY, g_total_tls_size);
|
||||
ASSERT(dynamic_object);
|
||||
bool success = loader->link(RTLD_GLOBAL | RTLD_LAZY, g_total_tls_size);
|
||||
ASSERT(success);
|
||||
|
||||
g_loaded_objects.set(name, *dynamic_object);
|
||||
g_global_objects.append(*dynamic_object);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue