Summary: This allows targets to also consider the symbol's type and/or address if needed.
Reviewers: scott.linder, jhenderson, MaskRay, aardappel
Reviewed By: scott.linder, MaskRay
Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, aheejin, rupprecht, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82090
/// Base implementation returns None. So all targets by default ignore to
/// treat symbols separately.
///
- /// \param Name - The name of the symbol.
+ /// \param Symbol - 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.
/// done by buffering the output if needed.
/// - None if the target doesn't want to handle the symbol
/// separately. Value of Size is ignored in this case.
- virtual Optional<DecodeStatus> onSymbolStart(StringRef Name, uint64_t &Size,
- ArrayRef<uint8_t> Bytes,
- uint64_t Address,
- raw_ostream &CStream) const;
+ virtual Optional<DecodeStatus>
+ onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> 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:
MCDisassembler::~MCDisassembler() = default;
Optional<MCDisassembler::DecodeStatus>
-MCDisassembler::onSymbolStart(StringRef Name, uint64_t &Size,
+MCDisassembler::onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &CStream) const {
return None;
DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &CStream) const override;
- Optional<DecodeStatus> onSymbolStart(StringRef Name, uint64_t &Size,
+ Optional<DecodeStatus> onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
ArrayRef<uint8_t> Bytes,
uint64_t Address,
raw_ostream &CStream) const override;
}
Optional<MCDisassembler::DecodeStatus> WebAssemblyDisassembler::onSymbolStart(
- StringRef Name, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address,
- raw_ostream &CStream) const {
+ SymbolInfoTy &Symbol, uint64_t &Size, ArrayRef<uint8_t> 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.
continue;
}
- auto Status = DisAsm->onSymbolStart(SymbolName, Size,
+ auto Status = DisAsm->onSymbolStart(Symbols[SI], Size,
Bytes.slice(Start, End - Start),
SectionAddr + Start, CommentStream);
// To have round trippable disassembly, we fall back to decoding the