LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::MCObjectSymbolizer Class Reference

An ObjectFile-backed symbolizer. More...

#include <MCObjectSymbolizer.h>

Inheritance diagram for llvm::MCObjectSymbolizer:
Inheritance graph
[legend]
Collaboration diagram for llvm::MCObjectSymbolizer:
Collaboration graph
[legend]

Public Member Functions

virtual StringRef findExternalFunctionAt (uint64_t Addr)
 Look for an external function symbol at Addr. (References through the ELF PLT, Mach-O stubs, and similar). More...
 
Overridden MCSymbolizer methods:
bool tryAddingSymbolicOperand (MCInst &MI, raw_ostream &cStream, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t InstSize)
 Try to add a symbolic operand instead of Value to the MCInst. More...
 
void tryAddingPcLoadReferenceComment (raw_ostream &cStream, int64_t Value, uint64_t Address)
 Try to add a comment on the PC-relative load. For instance, in Mach-O, this is used to add annotations to instructions that use C string literals, as found in __cstring. More...
 
- Public Member Functions inherited from llvm::MCSymbolizer
 MCSymbolizer (MCContext &Ctx, OwningPtr< MCRelocationInfo > &RelInfo)
 Construct an MCSymbolizer, taking ownership of RelInfo. More...
 
virtual ~MCSymbolizer ()
 

Static Public Member Functions

static MCObjectSymbolizercreateObjectSymbolizer (MCContext &Ctx, OwningPtr< MCRelocationInfo > &RelInfo, const object::ObjectFile *Obj)
 Create an object symbolizer for Obj. More...
 

Protected Member Functions

const object::RelocationReffindRelocationAt (uint64_t Addr)
 
const object::SectionReffindSectionContaining (uint64_t Addr)
 
 MCObjectSymbolizer (MCContext &Ctx, OwningPtr< MCRelocationInfo > &RelInfo, const object::ObjectFile *Obj)
 

Protected Attributes

const object::ObjectFileObj
 
- Protected Attributes inherited from llvm::MCSymbolizer
MCContextCtx
 
OwningPtr< MCRelocationInfoRelInfo
 

Detailed Description

An ObjectFile-backed symbolizer.

Definition at line 31 of file MCObjectSymbolizer.h.

Constructor & Destructor Documentation

MCObjectSymbolizer::MCObjectSymbolizer ( MCContext Ctx,
OwningPtr< MCRelocationInfo > &  RelInfo,
const object::ObjectFile Obj 
)
protected

Definition at line 128 of file MCObjectSymbolizer.cpp.

Referenced by createObjectSymbolizer().

Member Function Documentation

MCObjectSymbolizer * MCObjectSymbolizer::createObjectSymbolizer ( MCContext Ctx,
OwningPtr< MCRelocationInfo > &  RelInfo,
const object::ObjectFile Obj 
)
static

Create an object symbolizer for Obj.

Definition at line 199 of file MCObjectSymbolizer.cpp.

References MCObjectSymbolizer().

StringRef MCObjectSymbolizer::findExternalFunctionAt ( uint64_t  Addr)
virtual

Look for an external function symbol at Addr. (References through the ELF PLT, Mach-O stubs, and similar).

Returns
An MCExpr representing the external symbol, or 0 if not found.

Definition at line 194 of file MCObjectSymbolizer.cpp.

Referenced by llvm::MCObjectDisassembler::createFunction(), and tryAddingSymbolicOperand().

const RelocationRef * MCObjectSymbolizer::findRelocationAt ( uint64_t  Addr)
protected
const SectionRef * MCObjectSymbolizer::findSectionContaining ( uint64_t  Addr)
protected

Definition at line 214 of file MCObjectSymbolizer.cpp.

References SectionStartsBefore().

void MCObjectSymbolizer::tryAddingPcLoadReferenceComment ( raw_ostream cStream,
int64_t  Value,
uint64_t  Address 
)
virtual

Try to add a comment on the PC-relative load. For instance, in Mach-O, this is used to add annotations to instructions that use C string literals, as found in __cstring.

Implements llvm::MCSymbolizer.

Definition at line 190 of file MCObjectSymbolizer.cpp.

bool MCObjectSymbolizer::tryAddingSymbolicOperand ( MCInst Inst,
raw_ostream cStream,
int64_t  Value,
uint64_t  Address,
bool  IsBranch,
uint64_t  Offset,
uint64_t  InstSize 
)
virtual

Try to add a symbolic operand instead of Value to the MCInst.

Instead of having a difficult to read immediate, a symbolic operand would represent this immediate in a more understandable way, for instance as a symbol or an offset from a symbol. Relocations can also be used to enrich the symbolic expression.

Parameters
Inst- The MCInst where to insert the symbolic operand.
cStream- Stream to print comments and annotations on.
Value- Operand value, pc-adjusted by the caller if necessary.
Address- Load address of the instruction.
IsBranch- Is the instruction a branch?
Offset- Byte offset of the operand inside the inst.
InstSize- Size of the instruction in bytes.
Returns
Whether a symbolic operand was added.

Implements llvm::MCSymbolizer.

Definition at line 135 of file MCObjectSymbolizer.cpp.

References llvm::MCInst::addOperand(), llvm::object::ObjectFile::begin_symbols(), llvm::MCConstantExpr::Create(), llvm::MCSymbolRefExpr::Create(), llvm::MCBinaryExpr::CreateAdd(), llvm::MCOperand::CreateExpr(), llvm::MCRelocationInfo::createExprForRelocation(), llvm::StringRef::empty(), llvm::object::ObjectFile::end_symbols(), findExternalFunctionAt(), findRelocationAt(), llvm::MCContext::GetOrCreateSymbol(), llvm::object::content_iterator< content_type >::increment(), Obj, llvm::object::SymbolRef::ST_Function, and llvm::object::UnknownAddressOrSize.

Member Data Documentation

const object::ObjectFile* llvm::MCObjectSymbolizer::Obj
protected

Definition at line 33 of file MCObjectSymbolizer.h.

Referenced by tryAddingSymbolicOperand().


The documentation for this class was generated from the following files: