Index: include/llvm/MC/MCTargetMachine.h =================================================================== --- include/llvm/MC/MCTargetMachine.h +++ include/llvm/MC/MCTargetMachine.h @@ -15,6 +15,7 @@ #define LLVM_MC_MCTARGETMACHINE_H #include "llvm/ADT/Triple.h" +#include "llvm/MC/MCExternalSymbolizer.h" #include "llvm/Support/CodeGen.h" namespace llvm { @@ -29,8 +30,10 @@ class MCInstrAnalysis; class MCInstrInfo; class MCRegisterInfo; +class MCRelocationInfo; class MCStreamer; class MCSubtargetInfo; +class MCSymbolizer; class MCTargetAsmParser; class MCTargetOptions; class MCTargetStreamer; @@ -131,6 +134,28 @@ virtual MCStreamer *createNullStreamer(MCContext &Ctx) const; virtual MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const; + + /// createMCRelocationInfo - Create a target specific MCRelocationInfo. + /// + /// \param Ctx The target context. + MCRelocationInfo *createMCRelocationInfo(MCContext &Ctx) const; + + /// createMCSymbolizer - Create a target specific MCSymbolizer. + /// + /// \param GetOpInfo The function to get the symbolic information for + /// operands. + /// \param SymbolLookUp The function to lookup a symbol name. + /// \param DisInfo The pointer to the block of symbolic information for above + /// call + /// back. + /// \param Ctx The target context. + /// \param RelInfo The relocation information for this target. Takes + /// ownership. + MCSymbolizer * + createMCSymbolizer(LLVMOpInfoCallback GetOpInfo, + LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, + MCContext *Ctx, + std::unique_ptr &&RelInfo) const; }; } // End llvm namespace Index: include/llvm/Support/TargetRegistry.h =================================================================== --- include/llvm/Support/TargetRegistry.h +++ include/llvm/Support/TargetRegistry.h @@ -531,7 +531,6 @@ return nullptr; } -public: /// createMCRelocationInfo - Create a target specific MCRelocationInfo. /// /// \param TT The target triple. Index: lib/MC/MCDisassembler/CMakeLists.txt =================================================================== --- lib/MC/MCDisassembler/CMakeLists.txt +++ lib/MC/MCDisassembler/CMakeLists.txt @@ -3,4 +3,5 @@ MCRelocationInfo.cpp MCExternalSymbolizer.cpp MCDisassembler.cpp + MCTargetMachine.cpp ) Index: lib/MC/MCDisassembler/Disassembler.cpp =================================================================== --- lib/MC/MCDisassembler/Disassembler.cpp +++ lib/MC/MCDisassembler/Disassembler.cpp @@ -76,13 +76,12 @@ if (!DisAsm) return nullptr; - std::unique_ptr RelInfo( - TheTarget->createMCRelocationInfo(TTStr, *Ctx)); + std::unique_ptr RelInfo(MTM->createMCRelocationInfo(*Ctx)); if (!RelInfo) return nullptr; - std::unique_ptr Symbolizer(TheTarget->createMCSymbolizer( - TTStr, GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo))); + std::unique_ptr Symbolizer(MTM->createMCSymbolizer( + GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo))); DisAsm->setSymbolizer(std::move(Symbolizer)); // Set up the instruction printer. Index: lib/MC/MCDisassembler/MCTargetMachine.cpp =================================================================== --- /dev/null +++ lib/MC/MCDisassembler/MCTargetMachine.cpp @@ -0,0 +1,29 @@ +//===-- MCTargetMachine.cpp - General Target Information -------------------==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file describes the disassembler part of a MC Target machine. +// +//===----------------------------------------------------------------------===// + +#include "llvm/MC/MCTargetMachine.h" +#include "llvm/Support/TargetRegistry.h" +using namespace llvm; + +MCRelocationInfo * +MCTargetMachine::createMCRelocationInfo(MCContext &Ctx) const { + return TheTarget.createMCRelocationInfo(TheTriple.str(), Ctx); +} + +MCSymbolizer *MCTargetMachine::createMCSymbolizer( + LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, + void *DisInfo, MCContext *Ctx, + std::unique_ptr &&RelInfo) const { + return TheTarget.createMCSymbolizer(TheTriple.str(), GetOpInfo, SymbolLookUp, + DisInfo, Ctx, std::move(RelInfo)); +} Index: tools/llvm-objdump/MachODump.cpp =================================================================== --- tools/llvm-objdump/MachODump.cpp +++ tools/llvm-objdump/MachODump.cpp @@ -5960,12 +5960,11 @@ std::unique_ptr DisAsm(MTM->createMCDisassembler(*STI, Ctx)); std::unique_ptr Symbolizer; struct DisassembleInfo SymbolizerInfo; - std::unique_ptr RelInfo( - TheTarget->createMCRelocationInfo(TripleName, Ctx)); + std::unique_ptr RelInfo(MTM->createMCRelocationInfo(Ctx)); if (RelInfo) { - Symbolizer.reset(TheTarget->createMCSymbolizer( - TripleName, SymbolizerGetOpInfo, SymbolizerSymbolLookUp, - &SymbolizerInfo, &Ctx, std::move(RelInfo))); + Symbolizer.reset( + MTM->createMCSymbolizer(SymbolizerGetOpInfo, SymbolizerSymbolLookUp, + &SymbolizerInfo, &Ctx, std::move(RelInfo))); DisAsm->setSymbolizer(std::move(Symbolizer)); } int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); @@ -6010,12 +6009,11 @@ ThumbCtx.reset(new MCContext(ThumbAsmInfo.get(), ThumbMRI.get(), nullptr)); ThumbDisAsm.reset(ThumbMTM->createMCDisassembler(*ThumbSTI, *ThumbCtx)); MCContext *PtrThumbCtx = ThumbCtx.get(); - ThumbRelInfo.reset( - ThumbTarget->createMCRelocationInfo(ThumbTripleName, *PtrThumbCtx)); + ThumbRelInfo.reset(ThumbMTM->createMCRelocationInfo(*PtrThumbCtx)); if (ThumbRelInfo) { - ThumbSymbolizer.reset(ThumbTarget->createMCSymbolizer( - ThumbTripleName, SymbolizerGetOpInfo, SymbolizerSymbolLookUp, - &ThumbSymbolizerInfo, PtrThumbCtx, std::move(ThumbRelInfo))); + ThumbSymbolizer.reset(MTM->createMCSymbolizer( + SymbolizerGetOpInfo, SymbolizerSymbolLookUp, &ThumbSymbolizerInfo, + PtrThumbCtx, std::move(ThumbRelInfo))); ThumbDisAsm->setSymbolizer(std::move(ThumbSymbolizer)); } int ThumbAsmPrinterVariant = ThumbAsmInfo->getAssemblerDialect();