From 470c6e4ac6541fe79c849ad243e26d936393a575 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:48 +0000 Subject: [PATCH] MC CFG: Add an MCObjectSymbolizer in the MCObjectDisassembler. Used to detect calls to function symbol stubs (future commit). llvm-svn: 188887 --- include/llvm/MC/MCObjectDisassembler.h | 9 +++++++++ lib/MC/MCObjectDisassembler.cpp | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h index 4ac3456c464..ab317e3f931 100644 --- a/include/llvm/MC/MCObjectDisassembler.h +++ b/include/llvm/MC/MCObjectDisassembler.h @@ -31,6 +31,7 @@ class MCDisassembler; class MCFunction; class MCInstrAnalysis; class MCModule; +class MCObjectSymbolizer; /// \brief Disassemble an ObjectFile to an MCModule and MCFunctions. /// This class builds on MCDisassembler to disassemble whole sections, creating @@ -54,6 +55,13 @@ public: MCModule *buildEmptyModule(); + /// \brief Set the symbolizer to use to get information on external functions. + /// Note that this isn't used to do instruction-level symbolization (that is, + /// plugged into MCDisassembler), but to symbolize function call targets. + void setSymbolizer(MCObjectSymbolizer *ObjectSymbolizer) { + MOS = ObjectSymbolizer; + } + /// \brief Get the effective address of the entrypoint, or 0 if there is none. virtual uint64_t getEntrypoint(); @@ -86,6 +94,7 @@ protected: const object::ObjectFile &Obj; const MCDisassembler &Dis; const MCInstrAnalysis &MIA; + MCObjectSymbolizer *MOS; private: /// \brief Fill \p Module by creating an atom for each section. diff --git a/lib/MC/MCObjectDisassembler.cpp b/lib/MC/MCObjectDisassembler.cpp index 1969bcb4735..6b3ad836429 100644 --- a/lib/MC/MCObjectDisassembler.cpp +++ b/lib/MC/MCObjectDisassembler.cpp @@ -18,6 +18,7 @@ #include "llvm/MC/MCFunction.h" #include "llvm/MC/MCInstrAnalysis.h" #include "llvm/MC/MCModule.h" +#include "llvm/MC/MCObjectSymbolizer.h" #include "llvm/Object/MachO.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/Debug.h" @@ -34,7 +35,7 @@ using namespace object; MCObjectDisassembler::MCObjectDisassembler(const ObjectFile &Obj, const MCDisassembler &Dis, const MCInstrAnalysis &MIA) - : Obj(Obj), Dis(Dis), MIA(MIA) {} + : Obj(Obj), Dis(Dis), MIA(MIA), MOS(0) {} uint64_t MCObjectDisassembler::getEntrypoint() { error_code ec;