Index: test/MC/WebAssembly/debug-info.ll =================================================================== --- test/MC/WebAssembly/debug-info.ll +++ test/MC/WebAssembly/debug-info.ll @@ -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 [ Index: test/MC/WebAssembly/func-address.ll =================================================================== --- test/MC/WebAssembly/func-address.ll +++ test/MC/WebAssembly/func-address.ll @@ -24,26 +24,30 @@ 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: ] Index: test/MC/WebAssembly/reloc-code.ll =================================================================== --- test/MC/WebAssembly/reloc-code.ll +++ test/MC/WebAssembly/reloc-code.ll @@ -28,13 +28,13 @@ ; 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 @@ ; 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: ] Index: test/MC/WebAssembly/reloc-data.ll =================================================================== --- test/MC/WebAssembly/reloc-data.ll +++ test/MC/WebAssembly/reloc-data.ll @@ -17,31 +17,31 @@ ; 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: } Index: test/tools/llvm-readobj/relocations.test =================================================================== --- test/tools/llvm-readobj/relocations.test +++ test/tools/llvm-readobj/relocations.test @@ -291,18 +291,18 @@ 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: ] Index: tools/llvm-readobj/WasmDumper.cpp =================================================================== --- tools/llvm-readobj/WasmDumper.cpp +++ tools/llvm-readobj/WasmDumper.cpp @@ -80,6 +80,11 @@ 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 @@ 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";