14 #ifndef LLVM_OBJECT_OBJECTFILE_H
15 #define LLVM_OBJECT_OBJECTFILE_H
19 #include "llvm/Support/DataTypes.h"
31 class MachOObjectFile;
34 class symbol_iterator;
177 virtual void anchor();
262 virtual unsigned getArch()
const = 0;
336 return cast<ObjectFile>(O);
343 : SectionPimpl(SectionP)
344 , OwningObject(Owner) {}
347 return SectionPimpl == Other.SectionPimpl;
351 return SectionPimpl != Other.SectionPimpl;
355 return SectionPimpl < Other.SectionPimpl;
421 : RelocationPimpl(RelocationP)
422 , OwningObject(Owner) {}
425 return RelocationPimpl == Other.RelocationPimpl;
449 return RelocationPimpl;
static ErrorOr< std::unique_ptr< MachOObjectFile > > createMachOObjectFile(MemoryBufferRef Object)
Represents either an error or a value T.
iterator_range< symbol_iterator > symbol_iterator_range
iterator_range< section_iterator > section_iterator_range
DataRefImpl getRawDataRefImpl() const
static ErrorOr< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
const ObjectFile * getObject() const
const uint8_t * base() const
static std::error_code getObject(const T *&Obj, MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
symbol_iterator_range symbols() const
static ErrorOr< std::unique_ptr< COFFObjectFile > > createCOFFObjectFile(MemoryBufferRef Object)
virtual bool isSectionBSS(DataRefImpl Sec) const =0
This class is the base class for all object file types.
uint64_t getOffset() const
const char * getBufferStart() const
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
virtual std::error_code getSectionName(DataRefImpl Sec, StringRef &Res) const =0
static ErrorOr< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object)
DataRefImpl getRawDataRefImpl() const
section_iterator getRelocatedSection() const
virtual unsigned getArch() const =0
uint64_t getCommonSize() const
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
virtual std::error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const =0
virtual ErrorOr< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
virtual std::error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const =0
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
This is a value type class that represents a single relocation in the list of relocations in the obje...
SymbolRef::Type getType() const
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
bool containsSymbol(SymbolRef S) const
basic_symbol_iterator symbol_begin() const
virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const =0
std::error_code getName(StringRef &Result) const
virtual SymbolRef::Type getSymbolType(DataRefImpl Symb) const =0
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
const SymbolRef * operator->() const
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
content_iterator< SectionRef > section_iterator
virtual uint32_t getSymbolFlags(DataRefImpl Symb) const =0
virtual uint8_t getBytesInAddress() const =0
The number of bytes used to represent an address in this object file format.
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
relocation_iterator relocation_begin() const
The instances of the Type class are immutable: once they are created, they are never changed...
iterator_range< relocation_iterator > relocations() const
bool operator==(const RelocationRef &Other) const
symbol_iterator(const basic_symbol_iterator &B)
symbol_iterator getSymbol() const
virtual std::error_code getPlatformFlags(unsigned &Result) const
Returns platform-specific object flags, if any.
section_iterator_range sections() const
content_iterator< RelocationRef > relocation_iterator
uint64_t getAddress() const
const ObjectFile * getObject() const
basic_symbol_iterator symbol_end() const
SymbolRef(const BasicSymbolRef &B)
std::error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
virtual section_iterator section_begin() const =0
const ObjectFile * getObject() const
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
A range adaptor for a pair of iterators.
virtual section_iterator getRelocatedSection(DataRefImpl Sec) const
relocation_iterator relocation_end() const
virtual bool isSectionText(DataRefImpl Sec) const =0
std::error_code getContents(StringRef &Result) const
This is a value type class that represents a single symbol in the list of symbols in the object file...
static bool classof(const Binary *v)
ErrorOr< StringRef > getName() const
virtual void moveSectionNext(DataRefImpl &Sec) const =0
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
virtual section_iterator section_end() const =0
virtual bool isSectionData(DataRefImpl Sec) const =0
uint64_t getSymbolValue(DataRefImpl Symb) const
const SymbolicFile * getObject() const
This is a value type class that represents a single symbol in the list of symbols in the object file...
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const =0
const SymbolRef & operator*() const
virtual bool isRelocatableObject() const =0
True if this is a relocatable object (.o/.obj).
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
const content_type & operator*() const
bool operator==(const SectionRef &Other) const
bool operator<(const SectionRef &Other) const
virtual ErrorOr< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual bool isSectionVirtual(DataRefImpl Sec) const =0
virtual uint64_t getSectionSize(DataRefImpl Sec) const =0
virtual void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const =0
symbol_iterator(SymbolRef Sym)
This class implements an extremely fast bulk output stream that can only output to a stream...
uint64_t getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address...
static ErrorOr< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Create ObjectFile from path.
StringRef - Represent a constant reference to a string, i.e.
virtual StringRef getFileFormatName() const =0
ErrorOr< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
std::error_code getSection(section_iterator &Result) const
Get section this symbol is defined in reference to.
bool operator!=(const SectionRef &Other) const
This is a value type class that represents a single section in the list of sections in the object fil...
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
DataRefImpl getRawDataRefImpl() const