1 //===- bolt/Target/X86/X86MCSymbolizer.h ------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef BOLT_CORE_X86MCSYMBOLIZER_H 10 #define BOLT_CORE_X86MCSYMBOLIZER_H 11 12 #include "bolt/Core/BinaryFunction.h" 13 #include "llvm/MC/MCDisassembler/MCSymbolizer.h" 14 15 namespace llvm { 16 namespace bolt { 17 18 class X86MCSymbolizer : public MCSymbolizer { 19 protected: 20 BinaryFunction &Function; 21 bool CreateNewSymbols{true}; 22 23 Expected<std::pair<MCSymbol *, uint64_t>> handleGOTPC64(const Relocation &R, 24 uint64_t InstrAddr); 25 26 public: 27 X86MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true) 28 : MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr), 29 Function(Function), CreateNewSymbols(CreateNewSymbols) {} 30 31 X86MCSymbolizer(const X86MCSymbolizer &) = delete; 32 X86MCSymbolizer &operator=(const X86MCSymbolizer &) = delete; 33 virtual ~X86MCSymbolizer(); 34 35 bool tryAddingSymbolicOperand(MCInst &Inst, raw_ostream &CStream, 36 int64_t Value, uint64_t Address, bool IsBranch, 37 uint64_t Offset, uint64_t OpSize, 38 uint64_t InstSize) override; 39 40 void tryAddingPcLoadReferenceComment(raw_ostream &CStream, int64_t Value, 41 uint64_t Address) override; 42 }; 43 44 } // namespace bolt 45 } // namespace llvm 46 47 #endif 48