Add a test that would have found the bug in r219829.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 17 Oct 2014 01:34:23 +0000 (01:34 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 17 Oct 2014 01:34:23 +0000 (01:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220016 91177308-0d34-0410-b5e6-96231b3b80d8

test/MC/ELF/reloc-same-name-section.s [new file with mode: 0644]
tools/llvm-readobj/ELFDumper.cpp

diff --git a/test/MC/ELF/reloc-same-name-section.s b/test/MC/ELF/reloc-same-name-section.s
new file mode 100644 (file)
index 0000000..e63ea54
--- /dev/null
@@ -0,0 +1,31 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o - | llvm-readobj -r --expand-relocs | FileCheck %s
+
+// test that we produce one relocation against each section.
+
+// CHECK:      Relocations [
+// CHECK-NEXT:   Section {{.*}} {
+// CHECK-NEXT:     Relocation {
+// CHECK-NEXT:       Offset:
+// CHECK-NEXT:       Type:
+// CHECK-NEXT:       Symbol:  .foo (7)
+// CHECK-NEXT:       Addend:
+// CHECK-NEXT:     }
+// CHECK-NEXT:     Relocation {
+// CHECK-NEXT:       Offset:
+// CHECK-NEXT:       Type:
+// CHECK-NEXT:       Symbol:  .foo (8)
+// CHECK-NEXT:       Addend:
+// CHECK-NEXT:     }
+// CHECK-NEXT:   }
+// CHECK-NEXT: ]
+
+       .section        .foo,"aG",@progbits,v,comdat
+f:
+
+       .section        .foo,"a",@progbits
+g:
+
+
+       .section        .bar
+       .quad   f
+       .quad   g
index 6da3318..d68c786 100644 (file)
@@ -676,7 +676,8 @@ void ELFDumper<ELFT>::printRelocation(const Elf_Shdr *Sec,
     DictScope Group(W, "Relocation");
     W.printHex("Offset", Rel.r_offset);
     W.printNumber("Type", RelocName, (int)Rel.getType(Obj->isMips64EL()));
-    W.printString("Symbol", SymbolName.size() > 0 ? SymbolName : "-");
+    W.printNumber("Symbol", SymbolName.size() > 0 ? SymbolName : "-",
+                  Rel.getSymbol(Obj->isMips64EL()));
     W.printHex("Addend", Rel.r_addend);
   } else {
     raw_ostream& OS = W.startLine();