소스 검색

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 5 년 전
부모
커밋
43fbaf9970
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  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);