mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
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.
This commit is contained in:
parent
d30dbf47f5
commit
64b1740913
1 changed files with 5 additions and 2 deletions
|
@ -301,8 +301,11 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> load_main_library(co
|
||||||
auto& object = result.value();
|
auto& object = result.value();
|
||||||
|
|
||||||
if (loader.filename() == "libsystem.so"sv) {
|
if (loader.filename() == "libsystem.so"sv) {
|
||||||
if (syscall(SC_msyscall, object->base_address().as_ptr())) {
|
VERIFY(!loader.text_segments().is_empty());
|
||||||
VERIFY_NOT_REACHED();
|
for (const auto& segment : loader.text_segments()) {
|
||||||
|
if (syscall(SC_msyscall, segment.address().get())) {
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue