diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 96e409578f5c..64f60353d5f6 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -846,7 +846,7 @@ template static void addGotEntry(Symbol &Sym, bool Preemptible) { // // 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}); } diff --git a/lld/test/ELF/i386-got-value.s b/lld/test/ELF/i386-got-value.s index f42555b79272..8803fcffb312 100644 --- a/lld/test/ELF/i386-got-value.s +++ b/lld/test/ELF/i386-got-value.s @@ -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@GOT(%eax), %eax .data