From d62f9b681902bc65224bdc89162bd819609782e3 Mon Sep 17 00:00:00 2001 From: oddcoder <ahmedsoliman@oddcoder.com> Date: Fri, 8 May 2020 00:59:19 +0200 Subject: [PATCH] Fix regression in ld.so elf size calculation In patch 1182d1200603c9f33ec9968a1a00df5ebd3aa7d8, I mistakingly added the size of the gap to the total size of the binary, which was not accurate. As the size of the binary was calculate by subtracting the upperbound from the lower bound, thus all gaps in the middle are taking into account. --- src/ld_so/linker.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ld_so/linker.rs b/src/ld_so/linker.rs index 1b47d5c3..47331f5a 100644 --- a/src/ld_so/linker.rs +++ b/src/ld_so/linker.rs @@ -394,7 +394,7 @@ impl Linker { }; if same_elf { let addr = dso.as_ref().unwrap().base_addr; - let mut size = bounds.1; + let size = bounds.1; // Fill the gaps i the binary let mut ranges = Vec::new(); for ph in elf.program_headers.iter() { @@ -410,8 +410,6 @@ impl Linker { let mut start = addr; for (vaddr, vsize) in ranges.iter() { if start < addr + vaddr { - let gap_size = addr + vaddr - start; - size += gap_size; sys_mman::mmap( start as *mut c_void, addr + vaddr - start, -- GitLab