[lld] r321023 - Don't write preemptible symbol values to the .got.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 12:35:15 PST 2017


Author: rafael
Date: Mon Dec 18 12:35:15 2017
New Revision: 321023

URL: http://llvm.org/viewvc/llvm-project?rev=321023&view=rev
Log:
Don't write preemptible symbol values to the .got.

It is not necessary and matches what bfd and gold do.

This was a regression from r315658.

Modified:
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/test/ELF/i386-got-value.s

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=321023&r1=321022&r2=321023&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Mon Dec 18 12:35:15 2017
@@ -846,7 +846,7 @@ template <class ELFT> static void addGot
   //
   // This is ugly -- the difference between REL and RELA should be
   // handled in a better way. It's a TODO.
-  if (!Config->IsRela)
+  if (!Config->IsRela && !Preemptible)
     InX::Got->Relocations.push_back({R_ABS, Target->GotRel, Off, 0, &Sym});
 }
 

Modified: lld/trunk/test/ELF/i386-got-value.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-got-value.s?rev=321023&r1=321022&r2=321023&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-got-value.s (original)
+++ lld/trunk/test/ELF/i386-got-value.s Mon Dec 18 12:35:15 2017
@@ -1,10 +1,10 @@
 # RUN: llvm-mc %s -o %t.o -filetype=obj -triple=i386-pc-linux
 # RUN: ld.lld %t.o -o %t.so -shared
-# RUN: llvm-readobj --relocations --symbols --sections --section-data %t.so | FileCheck %s
+# RUN: llvm-readobj --relocations --sections --section-data %t.so | FileCheck %s
 
-# Check that the value of a preemptible symbol is written to the got
-# entry when using Elf_Rel. It is not clear why that is required, but
-# freebsd i386 seems to depend on it.
+# Check that the value of a preemptible symbol is not written to the
+# got entry when using Elf_Rel. It is not needed since the dynamic
+# linker will write the final value.
 
 # CHECK:      Name: .got
 # CHECK-NEXT: Type: SHT_PROGBITS
@@ -20,14 +20,11 @@
 # CHECK-NEXT: AddressAlignment:
 # CHECK-NEXT: EntrySize:
 # CHECK-NEXT: SectionData (
-# CHECK-NEXT:   0000: 00200000
+# CHECK-NEXT:   0000: 00000000
 # CHECK-NEXT: )
 
 # CHECK: R_386_GLOB_DAT bar 0x0
 
-# CHECK:      Name: bar
-# CHECK-NEXT: Value: 0x2000
-
         movl    bar at GOT(%eax), %eax
 
         .data




More information about the llvm-commits mailing list