From f3b762a0b6cef251afef8907cb4cf5b35bffb0d8 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Thu, 17 Jan 2019 18:14:09 +0000 Subject: [WebAssembly] Fixed objdump not parsing function headers. Summary: objdump was interpreting the function header containing the locals declaration as instructions. To parse these without injecting target specific code in objdump, MCDisassembler::onSymbolStart was added to be implemented by the WebAssembly implemention. WasmObjectFile now returns a code offset for the "address" of a symbol, rather than the index. This is also more in-line with what other targets do. Also ensured that the AsmParser correctly puts each function in its own segment to enable this test case. Reviewers: sbc100, dschuff Subscribers: jgravelle-google, aheejin, sunfish, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D56684 llvm-svn: 351460 --- llvm/tools/llvm-objdump/llvm-objdump.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp') diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index a4dbd07612f..7d0e7e94068 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1605,6 +1605,12 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) { raw_ostream &DebugOut = nulls(); #endif + // Some targets (like WebAssembly) have a special prelude at the start + // of each symbol. + DisAsm->onSymbolStart(SymbolName, Size, Bytes.slice(Start, End - Start), + SectionAddr + Start, DebugOut, CommentStream); + Start += Size; + for (Index = Start; Index < End; Index += Size) { MCInst Inst; -- cgit v1.2.3