From 410bde51717c3cf74f9a4d7e73f9bf03b613cafd Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 17 Oct 2014 01:34:23 +0000 Subject: [PATCH] Add a test that would have found the bug in r219829. 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 | 31 +++++++++++++++++++++++++++ tools/llvm-readobj/ELFDumper.cpp | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/MC/ELF/reloc-same-name-section.s diff --git a/test/MC/ELF/reloc-same-name-section.s b/test/MC/ELF/reloc-same-name-section.s new file mode 100644 index 00000000000..e63ea548e5a --- /dev/null +++ b/test/MC/ELF/reloc-same-name-section.s @@ -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 diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 6da3318c931..d68c78682d2 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -676,7 +676,8 @@ void ELFDumper::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(); -- 2.34.1