diff --git a/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h b/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h --- a/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h +++ b/llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h @@ -13,6 +13,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/XCOFF.h" #include "llvm/MC/MCDisassembler/MCSymbolizer.h" +#include "llvm/Object/ObjectFile.h" #include #include #include @@ -136,6 +137,7 @@ /// treat symbols separately. /// /// \param Symbol - The symbol. + /// \param Section - Section containing the symbol. /// \param Size - The number of bytes consumed. /// \param Address - The address, in the memory space of region, of the first /// byte of the symbol. @@ -151,8 +153,9 @@ /// - None if the target doesn't want to handle the symbol /// separately. Value of Size is ignored in this case. virtual Optional - onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef Bytes, - uint64_t Address, raw_ostream &CStream) const; + onSymbolStart(SymbolInfoTy &Symbol, const object::SectionRef &Section, + uint64_t &Size, ArrayRef Bytes, uint64_t Address, + raw_ostream &CStream) const; // TODO: // Implement similar hooks that can be used at other points during // disassembly. Something along the following lines: diff --git a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp --- a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp @@ -16,10 +16,9 @@ MCDisassembler::~MCDisassembler() = default; -Optional -MCDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, - ArrayRef Bytes, uint64_t Address, - raw_ostream &CStream) const { +Optional MCDisassembler::onSymbolStart( + SymbolInfoTy &Symbol, const object::SectionRef &Section, uint64_t &Size, + ArrayRef Bytes, uint64_t Address, raw_ostream &CStream) const { return None; } diff --git a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp --- a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -46,8 +46,9 @@ DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef Bytes, uint64_t Address, raw_ostream &CStream) const override; - Optional onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, - ArrayRef Bytes, + Optional onSymbolStart(SymbolInfoTy &Symbol, + const object::SectionRef &Section, + uint64_t &Size, ArrayRef Bytes, uint64_t Address, raw_ostream &CStream) const override; @@ -122,8 +123,8 @@ } Optional WebAssemblyDisassembler::onSymbolStart( - SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef Bytes, - uint64_t Address, raw_ostream &CStream) const { + SymbolInfoTy &Symbol, const object::SectionRef &Section, uint64_t &Size, + ArrayRef Bytes, uint64_t Address, raw_ostream &CStream) const { Size = 0; if (Address == 0) { // Start of a code section: we're parsing only the function count. diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1827,7 +1827,7 @@ continue; } - auto Status = DisAsm->onSymbolStart(Symbols[SI], Size, + auto Status = DisAsm->onSymbolStart(Symbols[SI], Section, Size, Bytes.slice(Start, End - Start), SectionAddr + Start, CommentStream); // To have round trippable disassembly, we fall back to decoding the