[llvm] r205416 - Work around gold bug http://sourceware.org/PR16794.

Rafael Espindola rafael.espindola at gmail.com
Wed Apr 2 05:15:20 PDT 2014


Author: rafael
Date: Wed Apr  2 07:15:20 2014
New Revision: 205416

URL: http://llvm.org/viewvc/llvm-project?rev=205416&view=rev
Log:
Work around gold bug http://sourceware.org/PR16794.

Modified:
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/test/MC/ELF/basic-elf-32.s
    llvm/trunk/test/MC/ELF/relocation-386.s

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=205416&r1=205415&r2=205416&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Apr  2 07:15:20 2014
@@ -796,6 +796,11 @@ bool ELFObjectWriter::shouldRelocateWith
   if (Flags & ELF::SHF_MERGE) {
     if (C != 0)
       return true;
+
+    // It looks like gold has a bug (http://sourceware.org/PR16794) and can
+    // only handle section relocations to mergeable sections if using RELA.
+    if (!hasRelocationAddend())
+      return true;
   }
 
   // Most TLS relocations use a got, so they need the symbol. Even those that

Modified: llvm/trunk/test/MC/ELF/basic-elf-32.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/basic-elf-32.s?rev=205416&r1=205415&r2=205416&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/basic-elf-32.s (original)
+++ llvm/trunk/test/MC/ELF/basic-elf-32.s Wed Apr  2 07:15:20 2014
@@ -46,9 +46,9 @@ main:
 
 // CHECK: Relocations [
 // CHECK:   Section (2) .rel.text {
-// CHECK:     0x6  R_386_32   .rodata.str1.1
+// CHECK:     0x6  R_386_32   .L.str1
 // CHECK:     0xB  R_386_PC32 puts
-// CHECK:     0x12 R_386_32   .rodata.str1.1
+// CHECK:     0x12 R_386_32   .L.str2
 // CHECK:     0x17 R_386_PC32 puts
 // CHECK:   }
 // CHECK: ]

Modified: llvm/trunk/test/MC/ELF/relocation-386.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation-386.s?rev=205416&r1=205415&r2=205416&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/relocation-386.s (original)
+++ llvm/trunk/test/MC/ELF/relocation-386.s Wed Apr  2 07:15:20 2014
@@ -5,7 +5,7 @@
 
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section (2) .rel.text {
-// CHECK-NEXT:     0x2          R_386_GOTOFF     .rodata.str1.16 0x0
+// CHECK-NEXT:     0x2          R_386_GOTOFF     .Lfoo 0x0
 // CHECK-NEXT:     0x{{[^ ]+}}  R_386_PLT32      bar2 0x0
 // CHECK-NEXT:     0x{{[^ ]+}}  R_386_GOTPC      _GLOBAL_OFFSET_TABLE_ 0x0
 // Relocation 3 (bar3 at GOTOFF) is done with symbol 7 (bss)





More information about the llvm-commits mailing list