From 181d12ec9311d9bb216f18b7774ed1d621fdc4ed Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Wed, 19 Nov 2014 16:46:18 +0100 Subject: [PATCH] Forward-port to LLVM 3.5 release --- src/disassembler/llvm/LLVMDisassembler.cxx | 20 ++++---- src/disassembler/llvm/LLVMDisassembler.hxx | 4 +- src/include_llvm.hxx | 55 +++++++++++----------- 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 76b313d..c2b0527 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -7,6 +7,7 @@ using namespace llvm; using namespace llvm::object; +using std::error_code; /* * TODO: fallback code falls die Datei kein ELF/PE/COFF/MacO/.. binary @@ -72,22 +73,25 @@ LLVMDisassembler::LLVMDisassembler(const std::string& filename) return; } - DisAsm.reset(target->createMCDisassembler(*STI)); + MOFI.reset(new MCObjectFileInfo); + MCContext Ctx(AsmInfo.get(), MRI.get(), MOFI.get()); + + DisAsm.reset(target->createMCDisassembler(*STI, Ctx)); if (!DisAsm) { LOG4CXX_ERROR(logger, "no disassembler for target " << tripleName); return; } - - MOFI.reset(new MCObjectFileInfo); - Ctx.reset(new MCContext(AsmInfo.get(), MRI.get(), MOFI.get())); RelInfo.reset( - target->createMCRelocationInfo(tripleName, *Ctx.get())); + target->createMCRelocationInfo(tripleName, Ctx)); if (RelInfo) { Symzer.reset( - MCObjectSymbolizer::createObjectSymbolizer(*Ctx.get(), RelInfo, o)); + MCObjectSymbolizer::createObjectSymbolizer(Ctx, std::move(RelInfo), o)); if (Symzer) - DisAsm->setSymbolizer(Symzer); + DisAsm->setSymbolizer(std::move(Symzer)); } + RelInfo.release(); + Symzer.release(); + MIA.reset(target->createMCInstrAnalysis(MII.get())); @@ -101,7 +105,7 @@ LLVMDisassembler::LLVMDisassembler(const std::string& filename) IP->setPrintImmHex(llvm::HexStyle::C); IP->setPrintImmHex(true); - OwningPtr OD( + std::unique_ptr OD( new MCObjectDisassembler(*o, *DisAsm, *MIA)); Mod.reset(OD->buildModule(false)); diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 52a7443..6ed3c8c 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -63,8 +63,8 @@ private: std::unique_ptr MIA; std::unique_ptr STI; std::unique_ptr MII; - llvm::OwningPtr RelInfo; - llvm::OwningPtr Symzer; + std::unique_ptr RelInfo; + std::unique_ptr Symzer; std::map sections; std::map symbols; diff --git a/src/include_llvm.hxx b/src/include_llvm.hxx index 41253f5..0ab21a3 100644 --- a/src/include_llvm.hxx +++ b/src/include_llvm.hxx @@ -1,32 +1,33 @@ #ifndef INCLUDE__include_llvm_hxx #define INCLUDE__include_llvm_hxx -#include "llvm/ADT/OwningPtr.h" -#include "llvm/ADT/Triple.h" -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/Object/ObjectFile.h" -#include "llvm/Object/Archive.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCAtom.h" -#include "llvm/MC/MCContext.h" -#include "llvm/MC/MCDisassembler.h" -#include "llvm/MC/MCFunction.h" -#include "llvm/MC/MCInst.h" -#include "llvm/MC/MCInstPrinter.h" -#include "llvm/MC/MCInstrAnalysis.h" -#include "llvm/MC/MCInstrInfo.h" -#include "llvm/MC/MCModule.h" -#include "llvm/MC/MCObjectDisassembler.h" -#include "llvm/MC/MCObjectFileInfo.h" -#include "llvm/MC/MCObjectSymbolizer.h" -#include "llvm/MC/MCRegisterInfo.h" -#include "llvm/MC/MCRelocationInfo.h" -#include "llvm/MC/MCSubtargetInfo.h" -#include "llvm/Support/TargetRegistry.h" -#include "llvm/Support/TargetSelect.h" -#include "llvm/Support/StringRefMemoryObject.h" -#include "llvm/Support/GraphWriter.h" +#define LLVM_OVERRIDE override + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif -- 2.39.5