Parcourir la source

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.
oddcoder il y a 5 ans
Parent
commit
d62f9b6819
1 fichiers modifiés avec 1 ajouts et 3 suppressions
  1. 1 3
      src/ld_so/linker.rs

+ 1 - 3
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,