summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibELF/DynamicLoader.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-31 11:46:00 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-31 11:46:00 +0100
commite313323317ea06b4d86a2b037b88123f522ba5bd (patch)
tree3ecb7403a00cb5c0eaccea97ea29e1b37d3b4731 /Userland/Libraries/LibELF/DynamicLoader.cpp
parent36525c057207060ba0fda1b13011a5b86528c08b (diff)
downloadserenity-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.cpp14
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);