summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-06-30 19:42:40 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-01 10:50:00 +0200
commit1f93ffcd729d778c68f6ed8cca161cd4907e1c66 (patch)
tree0f65d8104b8fa25b822251bb22cbdea7fcf29301 /Userland
parent2dbd3f83c10a1f5df9455ff9e038e6fdae659a49 (diff)
downloadserenity-1f93ffcd729d778c68f6ed8cca161cd4907e1c66.zip
LibELF: Simplify ELF load address calculations
These were unnecessarily complicated.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibELF/DynamicLoader.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp
index 2c9c89aa7f..7065b60380 100644
--- a/Userland/Libraries/LibELF/DynamicLoader.cpp
+++ b/Userland/Libraries/LibELF/DynamicLoader.cpp
@@ -321,10 +321,9 @@ void DynamicLoader::load_program_headers()
for (auto& text_region : text_regions) {
FlatPtr ph_text_base = text_region.desired_load_address().page_base().get();
FlatPtr ph_text_end = ph_text_base + round_up_to_power_of_two(text_region.size_in_memory() + (size_t)(text_region.desired_load_address().as_ptr() - ph_text_base), PAGE_SIZE);
- size_t text_segment_size = ph_text_end - ph_text_base;
- auto text_segment_offset = ph_text_base - ph_load_base;
- auto* text_segment_address = (u8*)reservation + text_segment_offset;
+ auto* text_segment_address = (u8*)reservation + ph_text_base;
+ size_t text_segment_size = ph_text_end - ph_text_base;
// Now we can map the text segment at the reserved address.
auto* text_segment_begin = (u8*)mmap_with_name(
@@ -359,10 +358,9 @@ void DynamicLoader::load_program_headers()
for (auto& data_region : data_regions) {
FlatPtr ph_data_base = data_region.desired_load_address().page_base().get();
FlatPtr ph_data_end = ph_data_base + round_up_to_power_of_two(data_region.size_in_memory() + (size_t)(data_region.desired_load_address().as_ptr() - ph_data_base), PAGE_SIZE);
- size_t data_segment_size = ph_data_end - ph_data_base;
- auto data_segment_offset = ph_data_base - ph_load_base;
- auto* data_segment_address = (u8*)reservation + data_segment_offset;
+ auto* data_segment_address = (u8*)reservation + ph_data_base;
+ size_t data_segment_size = ph_data_end - ph_data_base;
// Finally, we make an anonymous mapping for the data segment. Contents are then copied from the file.
auto* data_segment = (u8*)mmap_with_name(