diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-31 11:46:00 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-31 11:46:00 +0100 |
commit | e313323317ea06b4d86a2b037b88123f522ba5bd (patch) | |
tree | 3ecb7403a00cb5c0eaccea97ea29e1b37d3b4731 /Userland/Libraries/LibELF/DynamicLoader.cpp | |
parent | 36525c057207060ba0fda1b13011a5b86528c08b (diff) | |
download | serenity-e313323317ea06b4d86a2b037b88123f522ba5bd.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibELF/DynamicLoader.cpp')
-rw-r--r-- | Userland/Libraries/LibELF/DynamicLoader.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index 261484c641..8dbd7a1bb2 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -143,12 +143,12 @@ void* DynamicLoader::symbol_for_name(const char* name) return m_dynamic_object->base_address().offset(symbol.value()).as_ptr(); } -RefPtr<DynamicObject> DynamicLoader::load_from_image(unsigned flags, size_t total_tls_size) +RefPtr<DynamicObject> DynamicLoader::map() { ASSERT(!m_dynamic_object); if (!m_valid) { - dbgln("DynamicLoader::load_from_image failed: image is invalid"); + dbgln("DynamicLoader::map failed: image is invalid"); return nullptr; } @@ -158,14 +158,14 @@ RefPtr<DynamicObject> DynamicLoader::load_from_image(unsigned flags, size_t tota m_dynamic_object->set_tls_offset(m_tls_offset); m_dynamic_object->set_tls_size(m_tls_size); - auto rc = load_stage_2(flags, total_tls_size); - if (!rc) { - dbgln("DynamicLoader::load_from_image failed at load_stage_2"); - return nullptr; - } return m_dynamic_object; } +bool DynamicLoader::link(unsigned flags, size_t total_tls_size) +{ + return load_stage_2(flags, total_tls_size); +} + bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size) { ASSERT(flags & RTLD_GLOBAL); |