LLVM API Documentation
Disassemble an ObjectFile to an MCModule and MCFunctions. This class builds on MCDisassembler to disassemble whole sections, creating MCAtom (MCTextAtom for disassembled sections and MCDataAtom for raw data). It can also be used to create a control flow graph consisting of MCFunctions and MCBasicBlocks. More...
#include <MCObjectDisassembler.h>
Public Types | |
typedef std::vector< uint64_t > | AddressSetTy |
Public Member Functions | |
MCObjectDisassembler (const object::ObjectFile &Obj, const MCDisassembler &Dis, const MCInstrAnalysis &MIA) | |
virtual | ~MCObjectDisassembler () |
MCModule * | buildModule (bool withCFG=false) |
Build an MCModule, creating atoms and optionally functions. More... | |
MCModule * | buildEmptyModule () |
Create a new MCFunction. | |
MCFunction * | createFunction (MCModule *Module, uint64_t BeginAddr, AddressSetTy &CallTargets, AddressSetTy &TailCallTargets) |
void | setFallbackRegion (OwningPtr< MemoryObject > &Region) |
Set the region on which to fallback if disassembly was requested somewhere not accessible in the object file. This is used for dynamic disassembly (see RawMemoryObject). More... | |
void | setSymbolizer (MCObjectSymbolizer *ObjectSymbolizer) |
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. More... | |
virtual uint64_t | getEntrypoint () |
Get the effective address of the entrypoint, or 0 if there is none. More... | |
Get the addresses of static constructors/destructors in the object. | |
The caller is expected to know how to interpret the addresses; for example, Mach-O init functions expect 5 arguments, not for ELF. The addresses are original object file load addresses, not effective. | |
virtual ArrayRef< uint64_t > | getStaticInitFunctions () |
virtual ArrayRef< uint64_t > | getStaticExitFunctions () |
Translation between effective and objectfile load address. | |
Compute the effective load address, from an objectfile virtual address. This is implemented in a format-specific way, to take into account things like PIE/ASLR when doing dynamic disassembly. For example, on Mach-O this would be done by adding the VM addr slide, on glibc ELF by keeping a map between segment load addresses, filled using dl_iterate_phdr, etc.. In most static situations and in the default impl., this returns | |
virtual uint64_t | getEffectiveLoadAddr (uint64_t Addr) |
virtual uint64_t | getOriginalLoadAddr (uint64_t EffectiveAddr) |
Compute the original load address, as specified in the objectfile. This is the inverse of getEffectiveLoadAddr. More... | |
Protected Member Functions | |
MemoryObject * | getRegionFor (uint64_t Addr) |
Return a memory region suitable for reading starting at Addr . In most cases, this returns a StringRefMemoryObject backed by the containing section. When no section was found, this returns the FallbackRegion, if it is suitable. If it is not, or if there is no fallback region, this returns 0. More... | |
Protected Attributes | |
const object::ObjectFile & | Obj |
const MCDisassembler & | Dis |
const MCInstrAnalysis & | MIA |
MCObjectSymbolizer * | MOS |
OwningPtr< MemoryObject > | FallbackRegion |
The fallback memory region, outside the object file. More... | |
Disassemble an ObjectFile to an MCModule and MCFunctions. This class builds on MCDisassembler to disassemble whole sections, creating MCAtom (MCTextAtom for disassembled sections and MCDataAtom for raw data). It can also be used to create a control flow graph consisting of MCFunctions and MCBasicBlocks.
Definition at line 44 of file MCObjectDisassembler.h.
typedef std::vector<uint64_t> llvm::MCObjectDisassembler::AddressSetTy |
Definition at line 61 of file MCObjectDisassembler.h.
MCObjectDisassembler::MCObjectDisassembler | ( | const object::ObjectFile & | Obj, |
const MCDisassembler & | Dis, | ||
const MCInstrAnalysis & | MIA | ||
) |
Definition at line 34 of file MCObjectDisassembler.cpp.
|
inlinevirtual |
Definition at line 49 of file MCObjectDisassembler.h.
MCModule * MCObjectDisassembler::buildEmptyModule | ( | ) |
Definition at line 77 of file MCObjectDisassembler.cpp.
References getEntrypoint().
Referenced by buildModule().
Build an MCModule, creating atoms and optionally functions.
withCFG | Also build a CFG by adding MCFunctions to the Module. If withCFG is false, the MCModule built only contains atoms, representing what was found in the object file. If withCFG is true, MCFunctions are created, containing MCBasicBlocks. All text atoms are split to form basic block atoms, which then each back an MCBasicBlock. |
Definition at line 83 of file MCObjectDisassembler.cpp.
References buildEmptyModule().
MCFunction * MCObjectDisassembler::createFunction | ( | MCModule * | Module, |
uint64_t | BeginAddr, | ||
AddressSetTy & | CallTargets, | ||
AddressSetTy & | TailCallTargets | ||
) |
Definition at line 473 of file MCObjectDisassembler.cpp.
References llvm::MCModule::createFunction(), llvm::StringRef::empty(), llvm::MCObjectSymbolizer::findExternalFunctionAt(), llvm::MCModule::func_begin(), llvm::MCModule::func_end(), getOriginalLoadAddr(), and MOS.
|
virtual |
Reimplemented in llvm::MCMachOObjectDisassembler.
Definition at line 69 of file MCObjectDisassembler.cpp.
Referenced by getEntrypoint().
|
virtual |
Get the effective address of the entrypoint, or 0 if there is none.
Reimplemented in llvm::MCMachOObjectDisassembler.
Definition at line 39 of file MCObjectDisassembler.cpp.
References llvm::object::ObjectFile::begin_symbols(), llvm::object::ObjectFile::end_symbols(), getEffectiveLoadAddr(), llvm::object::content_iterator< content_type >::increment(), and Obj.
Referenced by buildEmptyModule(), and llvm::MCMachOObjectDisassembler::getEntrypoint().
|
virtual |
Compute the original load address, as specified in the objectfile. This is the inverse of getEffectiveLoadAddr.
Reimplemented in llvm::MCMachOObjectDisassembler.
Definition at line 73 of file MCObjectDisassembler.cpp.
Referenced by createFunction().
|
protected |
Return a memory region suitable for reading starting at Addr
. In most cases, this returns a StringRefMemoryObject backed by the containing section. When no section was found, this returns the FallbackRegion, if it is suitable. If it is not, or if there is no fallback region, this returns 0.
Definition at line 64 of file MCObjectDisassembler.cpp.
References FallbackRegion.
|
virtual |
Reimplemented in llvm::MCMachOObjectDisassembler.
Definition at line 60 of file MCObjectDisassembler.cpp.
|
virtual |
Reimplemented in llvm::MCMachOObjectDisassembler.
Definition at line 56 of file MCObjectDisassembler.cpp.
|
inline |
Set the region on which to fallback if disassembly was requested somewhere not accessible in the object file. This is used for dynamic disassembly (see RawMemoryObject).
Definition at line 70 of file MCObjectDisassembler.h.
References FallbackRegion, and llvm::OwningPtr< T >::take().
|
inline |
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.
Definition at line 77 of file MCObjectDisassembler.h.
References MOS.
|
protected |
Definition at line 111 of file MCObjectDisassembler.h.
|
protected |
The fallback memory region, outside the object file.
Definition at line 116 of file MCObjectDisassembler.h.
Referenced by getRegionFor(), and setFallbackRegion().
|
protected |
Definition at line 112 of file MCObjectDisassembler.h.
|
protected |
Definition at line 113 of file MCObjectDisassembler.h.
Referenced by createFunction(), and setSymbolizer().
|
protected |
Definition at line 110 of file MCObjectDisassembler.h.
Referenced by getEntrypoint().