Browse Source

Fix a bug in thread local reloations

There was a bug (also uncovered via binutils) where R_X86_64_DTPOFF64 is
set uncorrectly. This program is the minimal reproducer of the seg fault

  #include <errno.h>
  int main() {
        int oerrno = errno;
  }

But it works after the bug fix.
oddcoder 4 years ago
parent
commit
43fbaf9970
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/ld_so/linker.rs

+ 1 - 1
src/ld_so/linker.rs

@@ -666,7 +666,7 @@ impl Linker {
                         set_u64(tm as u64);
                     }
                     reloc::R_X86_64_DTPOFF64 => {
-                        set_u64((s + a) as u64);
+                        set_u64(rel.r_offset as u64);
                     }
                     reloc::R_X86_64_GLOB_DAT | reloc::R_X86_64_JUMP_SLOT => {
                         set_u64(s as u64);