LLVM  3.7.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
llvm::object::ObjectFile Class Referenceabstract

This class is the base class for all object file types. More...

#include <ObjectFile.h>

Inheritance diagram for llvm::object::ObjectFile:
[legend]
Collaboration diagram for llvm::object::ObjectFile:
[legend]

Public Types

typedef iterator_range
< symbol_iterator
symbol_iterator_range
 
typedef iterator_range
< section_iterator
section_iterator_range
 
- Public Types inherited from llvm::object::SymbolicFile
typedef iterator_range
< basic_symbol_iterator
basic_symbol_iterator_range
 

Public Member Functions

uint64_t getCommonSymbolSize (DataRefImpl Symb) const
 
symbol_iterator_range symbols () const
 
virtual section_iterator section_begin () const =0
 
virtual section_iterator section_end () const =0
 
section_iterator_range sections () const
 
virtual uint8_t getBytesInAddress () const =0
 The number of bytes used to represent an address in this object file format. More...
 
virtual StringRef getFileFormatName () const =0
 
virtual unsigned getArch () const =0
 
virtual std::error_code getPlatformFlags (unsigned &Result) const
 Returns platform-specific object flags, if any. More...
 
virtual bool isRelocatableObject () const =0
 True if this is a relocatable object (.o/.obj). More...
 
- Public Member Functions inherited from llvm::object::SymbolicFile
 ~SymbolicFile () override
 
 SymbolicFile (unsigned int Type, MemoryBufferRef Source)
 
virtual void moveSymbolNext (DataRefImpl &Symb) const =0
 
virtual uint32_t getSymbolFlags (DataRefImpl Symb) const =0
 
virtual basic_symbol_iterator symbol_begin_impl () const =0
 
virtual basic_symbol_iterator symbol_end_impl () const =0
 
basic_symbol_iterator symbol_begin () const
 
basic_symbol_iterator symbol_end () const
 
basic_symbol_iterator_range symbols () const
 
- Public Member Functions inherited from llvm::object::Binary
virtual ~Binary ()
 
StringRef getData () const
 
StringRef getFileName () const
 
MemoryBufferRef getMemoryBufferRef () const
 
unsigned int getType () const
 
bool isObject () const
 
bool isSymbolic () const
 
bool isArchive () const
 
bool isMachOUniversalBinary () const
 
bool isELF () const
 
bool isMachO () const
 
bool isCOFF () const
 
bool isIR () const
 
bool isLittleEndian () const
 

Static Public Member Functions

static ErrorOr< OwningBinary
< ObjectFile > > 
createObjectFile (StringRef ObjectPath)
 Create ObjectFile from path. More...
 
static ErrorOr
< std::unique_ptr< ObjectFile > > 
createObjectFile (MemoryBufferRef Object, sys::fs::file_magic Type)
 
static ErrorOr
< std::unique_ptr< ObjectFile > > 
createObjectFile (MemoryBufferRef Object)
 
static bool classof (const Binary *v)
 
static ErrorOr
< std::unique_ptr
< COFFObjectFile > > 
createCOFFObjectFile (MemoryBufferRef Object)
 
static ErrorOr
< std::unique_ptr< ObjectFile > > 
createELFObjectFile (MemoryBufferRef Object)
 
static ErrorOr
< std::unique_ptr
< MachOObjectFile > > 
createMachOObjectFile (MemoryBufferRef Object)
 
- Static Public Member Functions inherited from llvm::object::SymbolicFile
static ErrorOr
< std::unique_ptr
< SymbolicFile > > 
createSymbolicFile (MemoryBufferRef Object, sys::fs::file_magic Type, LLVMContext *Context)
 
static ErrorOr
< std::unique_ptr
< SymbolicFile > > 
createSymbolicFile (MemoryBufferRef Object)
 
static ErrorOr< OwningBinary
< SymbolicFile > > 
createSymbolicFile (StringRef ObjectPath)
 
static bool classof (const Binary *v)
 

Protected Member Functions

 ObjectFile (unsigned int Type, MemoryBufferRef Source)
 
const uint8_t * base () const
 
virtual ErrorOr< StringRefgetSymbolName (DataRefImpl Symb) const =0
 
std::error_code printSymbolName (raw_ostream &OS, DataRefImpl Symb) const override
 
virtual ErrorOr< uint64_t > getSymbolAddress (DataRefImpl Symb) const =0
 
virtual uint64_t getSymbolValueImpl (DataRefImpl Symb) const =0
 
virtual uint32_t getSymbolAlignment (DataRefImpl Symb) const
 
virtual uint64_t getCommonSymbolSizeImpl (DataRefImpl Symb) const =0
 
virtual SymbolRef::Type getSymbolType (DataRefImpl Symb) const =0
 
virtual std::error_code getSymbolSection (DataRefImpl Symb, section_iterator &Res) const =0
 
virtual void moveSectionNext (DataRefImpl &Sec) const =0
 
virtual std::error_code getSectionName (DataRefImpl Sec, StringRef &Res) const =0
 
virtual uint64_t getSectionAddress (DataRefImpl Sec) const =0
 
virtual uint64_t getSectionSize (DataRefImpl Sec) const =0
 
virtual std::error_code getSectionContents (DataRefImpl Sec, StringRef &Res) const =0
 
virtual uint64_t getSectionAlignment (DataRefImpl Sec) const =0
 
virtual bool isSectionText (DataRefImpl Sec) const =0
 
virtual bool isSectionData (DataRefImpl Sec) const =0
 
virtual bool isSectionBSS (DataRefImpl Sec) const =0
 
virtual bool isSectionVirtual (DataRefImpl Sec) const =0
 
virtual relocation_iterator section_rel_begin (DataRefImpl Sec) const =0
 
virtual relocation_iterator section_rel_end (DataRefImpl Sec) const =0
 
virtual section_iterator getRelocatedSection (DataRefImpl Sec) const
 
virtual void moveRelocationNext (DataRefImpl &Rel) const =0
 
virtual uint64_t getRelocationOffset (DataRefImpl Rel) const =0
 
virtual symbol_iterator getRelocationSymbol (DataRefImpl Rel) const =0
 
virtual uint64_t getRelocationType (DataRefImpl Rel) const =0
 
virtual void getRelocationTypeName (DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
 
uint64_t getSymbolValue (DataRefImpl Symb) const
 
- Protected Member Functions inherited from llvm::object::Binary
 Binary (unsigned int Type, MemoryBufferRef Source)
 

Friends

class SymbolRef
 
class SectionRef
 
class RelocationRef
 

Additional Inherited Members

- Protected Types inherited from llvm::object::Binary
enum  {
  ID_Archive, ID_MachOUniversalBinary, ID_IR, ID_StartObjects,
  ID_COFF, ID_ELF32L, ID_ELF32B, ID_ELF64L,
  ID_ELF64B, ID_MachO32L, ID_MachO32B, ID_MachO64L,
  ID_MachO64B, ID_EndObjects
}
 
- Static Protected Member Functions inherited from llvm::object::Binary
static unsigned int getELFType (bool isLE, bool is64Bits)
 
static unsigned int getMachOType (bool isLE, bool is64Bits)
 
- Protected Attributes inherited from llvm::object::Binary
MemoryBufferRef Data
 

Detailed Description

This class is the base class for all object file types.

Concrete instances of this object are created by createObjectFile, which figures out which type to create.

Definition at line 176 of file ObjectFile.h.

Member Typedef Documentation

Definition at line 252 of file ObjectFile.h.

Definition at line 244 of file ObjectFile.h.

Constructor & Destructor Documentation

ObjectFile::ObjectFile ( unsigned int  Type,
MemoryBufferRef  Source 
)
protected

Definition at line 28 of file ObjectFile.cpp.

Member Function Documentation

const uint8_t* llvm::object::ObjectFile::base ( ) const
inlineprotected
static bool llvm::object::ObjectFile::classof ( const Binary v)
inlinestatic

Definition at line 288 of file ObjectFile.h.

References llvm::object::Binary::isObject().

ErrorOr< std::unique_ptr< COFFObjectFile > > ObjectFile::createCOFFObjectFile ( MemoryBufferRef  Object)
static

Definition at line 1375 of file COFFObjectFile.cpp.

References llvm::MipsISD::Ret.

Referenced by createObjectFile().

ErrorOr< std::unique_ptr< ObjectFile > > llvm::ObjectFile::createELFObjectFile ( MemoryBufferRef  Object)
static
ErrorOr< std::unique_ptr< MachOObjectFile > > ObjectFile::createMachOObjectFile ( MemoryBufferRef  Object)
static
ErrorOr< OwningBinary< ObjectFile > > ObjectFile::createObjectFile ( StringRef  ObjectPath)
static

Create ObjectFile from path.

Returns
Pointer to ObjectFile subclass to handle this type of object.
Parameters
ObjectPathThe path to the object file. ObjectPath.isObject must return true.

Definition at line 102 of file ObjectFile.cpp.

References llvm::ErrorOr< T >::get(), llvm::ErrorOr< T >::getError(), and llvm::MemoryBuffer::getFile().

Referenced by createObjectFile(), llvm::object::SymbolicFile::createSymbolicFile(), llvm::object::IRObjectFile::findBitcodeInMemBuffer(), llvm::MCJIT::generateCodeForModule(), LLVMCreateObjectFile(), and llvm::orc::SimpleCompiler::operator()().

ErrorOr< std::unique_ptr< ObjectFile > > ObjectFile::createObjectFile ( MemoryBufferRef  Object,
sys::fs::file_magic  Type 
)
static
static ErrorOr<std::unique_ptr<ObjectFile> > llvm::object::ObjectFile::createObjectFile ( MemoryBufferRef  Object)
inlinestatic

Definition at line 283 of file ObjectFile.h.

References createObjectFile(), and llvm::sys::fs::file_magic::unknown.

virtual unsigned llvm::object::ObjectFile::getArch ( ) const
pure virtual
virtual uint8_t llvm::object::ObjectFile::getBytesInAddress ( ) const
pure virtual

The number of bytes used to represent an address in this object file format.

Implemented in llvm::object::COFFObjectFile, llvm::object::ELFObjectFile< ELFT >, and llvm::object::MachOObjectFile.

uint64_t llvm::object::ObjectFile::getCommonSymbolSize ( DataRefImpl  Symb) const
inline
virtual uint64_t llvm::object::ObjectFile::getCommonSymbolSizeImpl ( DataRefImpl  Symb) const
protectedpure virtual
virtual StringRef llvm::object::ObjectFile::getFileFormatName ( ) const
pure virtual
virtual std::error_code llvm::object::ObjectFile::getPlatformFlags ( unsigned Result) const
inlinevirtual

Returns platform-specific object flags, if any.

Reimplemented in llvm::object::ELFObjectFile< ELFT >.

Definition at line 265 of file ObjectFile.h.

References llvm::object::invalid_file_type.

section_iterator ObjectFile::getRelocatedSection ( DataRefImpl  Sec) const
protectedvirtual

Reimplemented in llvm::object::ELFObjectFile< ELFT >.

Definition at line 58 of file ObjectFile.cpp.

References SectionRef.

Referenced by llvm::object::SectionRef::getRelocatedSection().

virtual uint64_t llvm::object::ObjectFile::getRelocationOffset ( DataRefImpl  Rel) const
protectedpure virtual
virtual symbol_iterator llvm::object::ObjectFile::getRelocationSymbol ( DataRefImpl  Rel) const
protectedpure virtual
virtual uint64_t llvm::object::ObjectFile::getRelocationType ( DataRefImpl  Rel) const
protectedpure virtual
virtual void llvm::object::ObjectFile::getRelocationTypeName ( DataRefImpl  Rel,
SmallVectorImpl< char > &  Result 
) const
protectedpure virtual
virtual uint64_t llvm::object::ObjectFile::getSectionAddress ( DataRefImpl  Sec) const
protectedpure virtual
virtual uint64_t llvm::object::ObjectFile::getSectionAlignment ( DataRefImpl  Sec) const
protectedpure virtual
virtual std::error_code llvm::object::ObjectFile::getSectionContents ( DataRefImpl  Sec,
StringRef Res 
) const
protectedpure virtual
virtual std::error_code llvm::object::ObjectFile::getSectionName ( DataRefImpl  Sec,
StringRef Res 
) const
protectedpure virtual
virtual uint64_t llvm::object::ObjectFile::getSectionSize ( DataRefImpl  Sec) const
protectedpure virtual
virtual ErrorOr<uint64_t> llvm::object::ObjectFile::getSymbolAddress ( DataRefImpl  Symb) const
protectedpure virtual
uint32_t ObjectFile::getSymbolAlignment ( DataRefImpl  Symb) const
protectedvirtual
virtual ErrorOr<StringRef> llvm::object::ObjectFile::getSymbolName ( DataRefImpl  Symb) const
protectedpure virtual
virtual std::error_code llvm::object::ObjectFile::getSymbolSection ( DataRefImpl  Symb,
section_iterator Res 
) const
protectedpure virtual
virtual SymbolRef::Type llvm::object::ObjectFile::getSymbolType ( DataRefImpl  Symb) const
protectedpure virtual
uint64_t ObjectFile::getSymbolValue ( DataRefImpl  Symb) const
protected
virtual uint64_t llvm::object::ObjectFile::getSymbolValueImpl ( DataRefImpl  Symb) const
protectedpure virtual
virtual bool llvm::object::ObjectFile::isRelocatableObject ( ) const
pure virtual

True if this is a relocatable object (.o/.obj).

Implemented in llvm::object::COFFObjectFile, llvm::object::MachOObjectFile, and llvm::object::ELFObjectFile< ELFT >.

virtual bool llvm::object::ObjectFile::isSectionBSS ( DataRefImpl  Sec) const
protectedpure virtual
virtual bool llvm::object::ObjectFile::isSectionData ( DataRefImpl  Sec) const
protectedpure virtual
virtual bool llvm::object::ObjectFile::isSectionText ( DataRefImpl  Sec) const
protectedpure virtual
virtual bool llvm::object::ObjectFile::isSectionVirtual ( DataRefImpl  Sec) const
protectedpure virtual
virtual void llvm::object::ObjectFile::moveRelocationNext ( DataRefImpl Rel) const
protectedpure virtual
virtual void llvm::object::ObjectFile::moveSectionNext ( DataRefImpl Sec) const
protectedpure virtual
std::error_code ObjectFile::printSymbolName ( raw_ostream OS,
DataRefImpl  Symb 
) const
overrideprotectedvirtual

Implements llvm::object::SymbolicFile.

Definition at line 47 of file ObjectFile.cpp.

References llvm::ErrorOr< T >::getError(), and getSymbolName().

virtual section_iterator llvm::object::ObjectFile::section_begin ( ) const
pure virtual
virtual section_iterator llvm::object::ObjectFile::section_end ( ) const
pure virtual
virtual relocation_iterator llvm::object::ObjectFile::section_rel_begin ( DataRefImpl  Sec) const
protectedpure virtual
virtual relocation_iterator llvm::object::ObjectFile::section_rel_end ( DataRefImpl  Sec) const
protectedpure virtual
section_iterator_range llvm::object::ObjectFile::sections ( ) const
inline
symbol_iterator_range llvm::object::ObjectFile::symbols ( ) const
inline

Friends And Related Function Documentation

friend class RelocationRef
friend
friend class SectionRef
friend
friend class SymbolRef
friend

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