[llvm] 32ceee1 - Revert "[MC,x86-32] Remove a gold<2.34 workaround"

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 21:36:40 PDT 2023


Author: Arthur Eubanks
Date: 2023-06-29T21:19:07-07:00
New Revision: 32ceee13035687e7c9530d1bb9a27e181a24e970

URL: https://github.com/llvm/llvm-project/commit/32ceee13035687e7c9530d1bb9a27e181a24e970
DIFF: https://github.com/llvm/llvm-project/commit/32ceee13035687e7c9530d1bb9a27e181a24e970.diff

LOG: Revert "[MC,x86-32] Remove a gold<2.34 workaround"

This reverts commit a699921baa91e6c2979ec0f0482430c57f51761d.

Seems to cause miscompiles (https://crbug.com/1459232), following up with author.

Added: 
    

Modified: 
    llvm/lib/MC/ELFObjectWriter.cpp
    llvm/test/MC/ELF/relocation-386.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 66e2f0a6d15e95..6a6befdd305492 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1386,6 +1386,12 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
       if (C != 0)
         return true;
 
+      // gold<2.34 incorrectly ignored the addend for R_386_GOTOFF (9)
+      // (http://sourceware.org/PR16794).
+      if (TargetObjectWriter->getEMachine() == ELF::EM_386 &&
+          Type == ELF::R_386_GOTOFF)
+        return true;
+
       // ld.lld handles R_MIPS_HI16/R_MIPS_LO16 separately, not as a whole, so
       // it doesn't know that an R_MIPS_HI16 with implicit addend 1 and an
       // R_MIPS_LO16 with implicit addend -32768 represents 32768, which is in

diff  --git a/llvm/test/MC/ELF/relocation-386.s b/llvm/test/MC/ELF/relocation-386.s
index dbabbe6d190d54..e49b25a25ce53b 100644
--- a/llvm/test/MC/ELF/relocation-386.s
+++ b/llvm/test/MC/ELF/relocation-386.s
@@ -10,7 +10,7 @@
 // CHECK-NEXT:   Section {{.*}} .rel.text {
 /// Do not use STT_SECTION symbol for R_386_GOTOFF to work around a gold<2.34 bug
 /// https://sourceware.org/bugzilla/show_bug.cgi?id=16794
-// I386-NEXT:      0x2          R_386_GOTOFF     .rodata.str1.1
+// I386-NEXT:      0x2          R_386_GOTOFF     .Lfoo
 // IAMCU-NEXT:     0x2          R_386_GOTOFF     .rodata.str1.1
 // CHECK-NEXT:     0x{{[^ ]+}}  R_386_PLT32      bar2
 // CHECK-NEXT:     0x{{[^ ]+}}  R_386_GOTPC      _GLOBAL_OFFSET_TABLE_


        


More information about the llvm-commits mailing list