From 3fd2462d031f9a9ee15f4fdef1177dd4fe942bad Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 4 Feb 2019 22:27:46 +0000 Subject: [PATCH] [llvm-readobj] Report more WebAssembly symbol info Differential Revision: https://reviews.llvm.org/D57695 llvm-svn: 353104 --- llvm/test/MC/WebAssembly/debug-info.ll | 12 ++++++++++++ llvm/tools/llvm-readobj/WasmDumper.cpp | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/llvm/test/MC/WebAssembly/debug-info.ll b/llvm/test/MC/WebAssembly/debug-info.ll index b923301..55b9eac 100644 --- a/llvm/test/MC/WebAssembly/debug-info.ll +++ b/llvm/test/MC/WebAssembly/debug-info.ll @@ -166,41 +166,53 @@ ; CHECK-NEXT: Name: f2 ; CHECK-NEXT: Type: FUNCTION (0x0) ; CHECK-NEXT: Flags: 0x4 +; CHECK-NEXT: ElementIndex: 0x0 ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: foo ; CHECK-NEXT: Type: DATA (0x1) ; CHECK-NEXT: Flags: 0x4 +; CHECK-NEXT: Offset: 0x0 +; CHECK-NEXT: Segment: 0x0 +; CHECK-NEXT: Size: 0x4 ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: myextern ; CHECK-NEXT: Type: DATA (0x1) ; CHECK-NEXT: Flags: 0x10 +; CHECK-NEXT: Module: ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: ptr2 ; CHECK-NEXT: Type: DATA (0x1) ; CHECK-NEXT: Flags: 0x4 +; CHECK-NEXT: Offset: 0x0 +; CHECK-NEXT: Segment: 0x1 +; CHECK-NEXT: Size: 0x4 ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: .debug_str ; CHECK-NEXT: Type: SECTION (0x3) ; CHECK-NEXT: Flags: 0x2 +; CHECK-NEXT: ElementIndex: 0x6 ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: .debug_abbrev ; CHECK-NEXT: Type: SECTION (0x3) ; CHECK-NEXT: Flags: 0x2 +; CHECK-NEXT: ElementIndex: 0x7 ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: .debug_info ; CHECK-NEXT: Type: SECTION (0x3) ; CHECK-NEXT: Flags: 0x2 +; CHECK-NEXT: ElementIndex: 0x8 ; CHECK-NEXT: } ; CHECK-NEXT: Symbol { ; CHECK-NEXT: Name: .debug_line ; CHECK-NEXT: Type: SECTION (0x3) ; CHECK-NEXT: Flags: 0x2 +; CHECK-NEXT: ElementIndex: 0xC ; CHECK-NEXT: } ; CHECK-NEXT:] diff --git a/llvm/tools/llvm-readobj/WasmDumper.cpp b/llvm/tools/llvm-readobj/WasmDumper.cpp index 1609487..e8440f6 100644 --- a/llvm/tools/llvm-readobj/WasmDumper.cpp +++ b/llvm/tools/llvm-readobj/WasmDumper.cpp @@ -210,6 +210,15 @@ void WasmDumper::printSymbol(const SymbolRef &Sym) { W.printString("Name", Symbol.Info.Name); W.printEnum("Type", Symbol.Info.Kind, makeArrayRef(WasmSymbolTypes)); W.printHex("Flags", Symbol.Info.Flags); + if (Symbol.Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) + W.printString("Module", Symbol.Info.Module); + if (Symbol.Info.Kind != wasm::WASM_SYMBOL_TYPE_DATA) { + W.printHex("ElementIndex", Symbol.Info.ElementIndex); + } else if (!(Symbol.Info.Flags & wasm::WASM_SYMBOL_UNDEFINED)) { + W.printHex("Offset", Symbol.Info.DataRef.Offset); + W.printHex("Segment", Symbol.Info.DataRef.Segment); + W.printHex("Size", Symbol.Info.DataRef.Size); + } } } // namespace -- 2.7.4