[llvm] r331279 - [WebAssembly] llvm-readobj: display symbols names in relocations
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue May 1 09:35:16 PDT 2018
Author: sbc
Date: Tue May 1 09:35:16 2018
New Revision: 331279
URL: http://llvm.org/viewvc/llvm-project?rev=331279&view=rev
Log:
[WebAssembly] llvm-readobj: display symbols names in relocations
Differential Revision: https://reviews.llvm.org/D46296
Modified:
llvm/trunk/test/MC/WebAssembly/debug-info.ll
llvm/trunk/test/MC/WebAssembly/func-address.ll
llvm/trunk/test/MC/WebAssembly/reloc-code.ll
llvm/trunk/test/MC/WebAssembly/reloc-data.ll
llvm/trunk/test/tools/llvm-readobj/relocations.test
llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
Modified: llvm/trunk/test/MC/WebAssembly/debug-info.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/debug-info.ll?rev=331279&r1=331278&r2=331279&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/debug-info.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/debug-info.ll Tue May 1 09:35:16 2018
@@ -133,32 +133,32 @@
; CHECK-NEXT:]
; CHECK-NEXT:Relocations [
; CHECK-NEXT: Section (6) DATA {
-; CHECK-NEXT: 0x6 R_WEBASSEMBLY_MEMORY_ADDR_I32[10] 0
-; CHECK-NEXT: 0xF R_WEBASSEMBLY_TABLE_INDEX_I32[8]
+; CHECK-NEXT: 0x6 R_WEBASSEMBLY_MEMORY_ADDR_I32 myextern 0
+; CHECK-NEXT: 0xF R_WEBASSEMBLY_TABLE_INDEX_I32 f2
; CHECK-NEXT: }
; CHECK-NEXT: Section (9) .debug_info {
-; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32[1] 0
-; CHECK-NEXT: 0xC R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 0
-; CHECK-NEXT: 0x12 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 55
-; CHECK-NEXT: 0x16 R_WEBASSEMBLY_SECTION_OFFSET_I32[7] 0
-; CHECK-NEXT: 0x1A R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 62
-; CHECK-NEXT: 0x1E R_WEBASSEMBLY_FUNCTION_OFFSET_I32[8] 0
-; CHECK-NEXT: 0x27 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 105
-; CHECK-NEXT: 0x33 R_WEBASSEMBLY_MEMORY_ADDR_I32[9] 0
-; CHECK-NEXT: 0x3D R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 109
-; CHECK-NEXT: 0x44 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 113
-; CHECK-NEXT: 0x50 R_WEBASSEMBLY_MEMORY_ADDR_I32[11] 0
-; CHECK-NEXT: 0x5B R_WEBASSEMBLY_FUNCTION_OFFSET_I32[8] 0
-; CHECK-NEXT: 0x63 R_WEBASSEMBLY_SECTION_OFFSET_I32[0] 118
+; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_abbrev 0
+; CHECK-NEXT: 0xC R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 0
+; CHECK-NEXT: 0x12 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 55
+; CHECK-NEXT: 0x16 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_line 0
+; CHECK-NEXT: 0x1A R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 62
+; CHECK-NEXT: 0x1E R_WEBASSEMBLY_FUNCTION_OFFSET_I32 f2 0
+; CHECK-NEXT: 0x27 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 105
+; CHECK-NEXT: 0x33 R_WEBASSEMBLY_MEMORY_ADDR_I32 foo 0
+; CHECK-NEXT: 0x3D R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 109
+; CHECK-NEXT: 0x44 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 113
+; CHECK-NEXT: 0x50 R_WEBASSEMBLY_MEMORY_ADDR_I32 ptr2 0
+; CHECK-NEXT: 0x5B R_WEBASSEMBLY_FUNCTION_OFFSET_I32 f2 0
+; CHECK-NEXT: 0x63 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_str 118
; CHECK-NEXT: }
; CHECK-NEXT: Section (12) .debug_pubnames {
-; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32[2] 0
+; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
; CHECK-NEXT: Section (13) .debug_pubtypes {
-; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32[2] 0
+; CHECK-NEXT: 0x6 R_WEBASSEMBLY_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
; CHECK-NEXT: Section (14) .debug_line {
-; CHECK-NEXT: 0x2B R_WEBASSEMBLY_FUNCTION_OFFSET_I32[8] 0
+; CHECK-NEXT: 0x2B R_WEBASSEMBLY_FUNCTION_OFFSET_I32 f2 0
; CHECK-NEXT: }
; CHECK-NEXT:]
; CHECK-NEXT:Symbols [
Modified: llvm/trunk/test/MC/WebAssembly/func-address.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/func-address.ll?rev=331279&r1=331278&r2=331279&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/func-address.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/func-address.ll Tue May 1 09:35:16 2018
@@ -24,26 +24,30 @@ entry:
ret void
}
-; CHECK: Section {
-; CHECK: Type: ELEM (0x9)
-; CHECK: Size: 7
-; CHECK: }
+; CHECK: Type: ELEM (0x9)
+; CHECK-NEXT: Size: 7
-; CHECK: Relocations [
-; CHECK: Section (5) CODE {
-; CHECK: Relocation {
-; CHECK: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
-; CHECK: Offset: 0x4
-; CHECK: Index: 0x1
-; CHECK: }
-; CHECK: Relocation {
-; CHECK: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
-; CHECK: Offset: 0xB
-; CHECK: Index: 0x2
-; CHECK: }
-; CHECK: Relocation {
-; CHECK: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
-; CHECK: Offset: 0x1E
-; CHECK: Index: 0x5
-; CHECK: }
-; CHECK: }
+; CHECK: Relocations [
+; CHECK-NEXT: Section (5) CODE {
+; CHECK-NEXT: Relocation {
+; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
+; CHECK-NEXT: Offset: 0x4
+; CHECK-NEXT: Symbol: import1
+; CHECK-NEXT: }
+; CHECK-NEXT: Relocation {
+; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
+; CHECK-NEXT: Offset: 0xB
+; CHECK-NEXT: Symbol: import2
+; CHECK-NEXT: }
+; CHECK-NEXT: Relocation {
+; CHECK-NEXT: Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB (7)
+; CHECK-NEXT: Offset: 0x15
+; CHECK-NEXT: Symbol: __stack_pointer
+; CHECK-NEXT: }
+; CHECK-NEXT: Relocation {
+; CHECK-NEXT: Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
+; CHECK-NEXT: Offset: 0x1E
+; CHECK-NEXT: Symbol: import3
+; CHECK-NEXT: }
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
Modified: llvm/trunk/test/MC/WebAssembly/reloc-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-code.ll?rev=331279&r1=331278&r2=331279&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-code.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-code.ll Tue May 1 09:35:16 2018
@@ -28,13 +28,13 @@ entry:
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
; CHECK-NEXT: Offset: 0x9
-; CHECK-NEXT: Index: 0x1
+; CHECK-NEXT: Symbol: b
; CHECK-NEXT: Addend: 0
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
; CHECK-NEXT: Offset: 0x14
-; CHECK-NEXT: Index: 0x2
+; CHECK-NEXT: Symbol: a
; CHECK-NEXT: Addend: 0
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
@@ -50,12 +50,12 @@ entry:
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
; CHECK-NEXT: Offset: 0x2D
-; CHECK-NEXT: Index: 0x3
+; CHECK-NEXT: Symbol: c
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
; CHECK-NEXT: Offset: 0x34
-; CHECK-NEXT: Index: 0x4
+; CHECK-NEXT: Symbol: d
; CHECK-NEXT: }
; CHECK-NEXT: }
; CHECK-NEXT: ]
Modified: llvm/trunk/test/MC/WebAssembly/reloc-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-data.ll?rev=331279&r1=331278&r2=331279&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-data.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-data.ll Tue May 1 09:35:16 2018
@@ -17,31 +17,31 @@ target triple = "wasm32-unknown-unknown-
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK-NEXT: Offset: 0x13
-; CHECK-NEXT: Index: 0x2
+; CHECK-NEXT: Symbol: foo
; CHECK-NEXT: Addend: 8
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK-NEXT: Offset: 0x1C
-; CHECK-NEXT: Index: 0x0
+; CHECK-NEXT: Symbol: bar
; CHECK-NEXT: Addend: -16
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK-NEXT: Offset: 0x25
-; CHECK-NEXT: Index: 0x2
+; CHECK-NEXT: Symbol: foo
; CHECK-NEXT: Addend: 0
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK-NEXT: Offset: 0x29
-; CHECK-NEXT: Index: 0x2
+; CHECK-NEXT: Symbol: foo
; CHECK-NEXT: Addend: 0
; CHECK-NEXT: }
; CHECK-NEXT: Relocation {
; CHECK-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
; CHECK-NEXT: Offset: 0x2D
-; CHECK-NEXT: Index: 0x2
+; CHECK-NEXT: Symbol: foo
; CHECK-NEXT: Addend: 0
; CHECK-NEXT: }
; CHECK-NEXT: }
Modified: llvm/trunk/test/tools/llvm-readobj/relocations.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/relocations.test?rev=331279&r1=331278&r2=331279&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/relocations.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/relocations.test Tue May 1 09:35:16 2018
@@ -291,18 +291,18 @@ WASM-NEXT: Section (4) CODE {
WASM-NEXT: Relocation {
WASM-NEXT: Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB (4)
WASM-NEXT: Offset: 0x4
-WASM-NEXT: Index: 0x1
+WASM-NEXT: Symbol: .L.str
WASM-NEXT: Addend: 0
WASM-NEXT: }
WASM-NEXT: Relocation {
WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
WASM-NEXT: Offset: 0xA
-WASM-NEXT: Index: 0x2
+WASM-NEXT: Symbol: puts
WASM-NEXT: }
WASM-NEXT: Relocation {
WASM-NEXT: Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
WASM-NEXT: Offset: 0x11
-WASM-NEXT: Index: 0x3
+WASM-NEXT: Symbol: SomeOtherFunction
WASM-NEXT: }
WASM-NEXT: }
WASM-NEXT: ]
Modified: llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/WasmDumper.cpp?rev=331279&r1=331278&r2=331279&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/WasmDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/WasmDumper.cpp Tue May 1 09:35:16 2018
@@ -80,6 +80,11 @@ void WasmDumper::printRelocation(const S
Reloc.getTypeName(RelocTypeName);
const wasm::WasmRelocation &WasmReloc = Obj->getWasmRelocation(Reloc);
+ StringRef SymName;
+ symbol_iterator SI = Reloc.getSymbol();
+ if (SI != Obj->symbol_end())
+ SymName = error(SI->getName());
+
bool HasAddend = false;
switch (RelocType) {
case wasm::R_WEBASSEMBLY_MEMORY_ADDR_LEB:
@@ -96,13 +101,19 @@ void WasmDumper::printRelocation(const S
DictScope Group(W, "Relocation");
W.printNumber("Type", RelocTypeName, RelocType);
W.printHex("Offset", Reloc.getOffset());
- W.printHex("Index", WasmReloc.Index);
+ if (!SymName.empty())
+ W.printString("Symbol", SymName);
+ else
+ W.printHex("Index", WasmReloc.Index);
if (HasAddend)
W.printNumber("Addend", WasmReloc.Addend);
} else {
raw_ostream& OS = W.startLine();
- OS << W.hex(Reloc.getOffset()) << " " << RelocTypeName << "["
- << WasmReloc.Index << "]";
+ OS << W.hex(Reloc.getOffset()) << " " << RelocTypeName << " ";
+ if (!SymName.empty())
+ OS << SymName;
+ else
+ OS << WasmReloc.Index;
if (HasAddend)
OS << " " << WasmReloc.Addend;
OS << "\n";
More information about the llvm-commits
mailing list