summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibELF/DynamicLinker.cpp
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-07-07 20:46:09 +0200
committerGunnar Beutner <gunnar@beutner.name>2021-07-07 22:26:53 +0200
commit64b1740913743bd61f2c01bece3809614e628df4 (patch)
tree8c4478e1fd99e6241819dcc972e0adbe2c641171 /Userland/Libraries/LibELF/DynamicLinker.cpp
parentd30dbf47f569fa798040e201b8daf423c29a1f49 (diff)
downloadserenity-64b1740913743bd61f2c01bece3809614e628df4.zip
LibELF: Fix syscall regions for .text segments with a non-zero offset
Previously, we assumed that the `.text` segment was loaded at vaddr 0 in all dynamic libraries, so we used the dynamic object's base address with `msyscall`. This did not work with the LLVM toolchain, as it likes to shuffle these segments around. This now also handles the case when there are multiple text segments for some reason correctly.
Diffstat (limited to 'Userland/Libraries/LibELF/DynamicLinker.cpp')
-rw-r--r--Userland/Libraries/LibELF/DynamicLinker.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp
index 06eb3425be..cc93fea4ed 100644
--- a/Userland/Libraries/LibELF/DynamicLinker.cpp
+++ b/Userland/Libraries/LibELF/DynamicLinker.cpp
@@ -301,8 +301,11 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> load_main_library(co
auto& object = result.value();
if (loader.filename() == "libsystem.so"sv) {
- if (syscall(SC_msyscall, object->base_address().as_ptr())) {
- VERIFY_NOT_REACHED();
+ VERIFY(!loader.text_segments().is_empty());
+ for (const auto& segment : loader.text_segments()) {
+ if (syscall(SC_msyscall, segment.address().get())) {
+ VERIFY_NOT_REACHED();
+ }
}
}