14 #ifndef LLVM_OBJECT_OBJECTFILE_H 15 #define LLVM_OBJECT_OBJECTFILE_H 32 #include <system_error> 36 class ARMAttributeParser;
41 class MachOObjectFile;
45 class symbol_iterator;
98 uint64_t getAddress()
const;
99 uint64_t getIndex()
const;
100 uint64_t getSize()
const;
106 bool isCompressed()
const;
110 bool isVirtual()
const;
112 bool isStripped()
const;
119 return make_range(relocation_begin(), relocation_end());
155 uint64_t getValue()
const;
159 uint64_t getCommonSize()
const;
191 virtual void anchor();
197 return reinterpret_cast<const uint8_t *
>(
Data.getBufferStart());
214 virtual uint64_t getSymbolValueImpl(
DataRefImpl Symb)
const = 0;
216 virtual uint64_t getCommonSymbolSizeImpl(
DataRefImpl Symb)
const = 0;
224 virtual void moveSectionNext(
DataRefImpl &Sec)
const = 0;
225 virtual std::error_code getSectionName(
DataRefImpl Sec,
227 virtual uint64_t getSectionAddress(
DataRefImpl Sec)
const = 0;
228 virtual uint64_t getSectionIndex(
DataRefImpl Sec)
const = 0;
229 virtual uint64_t getSectionSize(
DataRefImpl Sec)
const = 0;
230 virtual std::error_code getSectionContents(
DataRefImpl Sec,
232 virtual uint64_t getSectionAlignment(
DataRefImpl Sec)
const = 0;
233 virtual bool isSectionCompressed(
DataRefImpl Sec)
const = 0;
234 virtual bool isSectionText(
DataRefImpl Sec)
const = 0;
235 virtual bool isSectionData(
DataRefImpl Sec)
const = 0;
236 virtual bool isSectionBSS(
DataRefImpl Sec)
const = 0;
238 virtual bool isSectionVirtual(
DataRefImpl Sec)
const = 0;
239 virtual bool isSectionBitcode(
DataRefImpl Sec)
const;
240 virtual bool isSectionStripped(
DataRefImpl Sec)
const;
247 virtual void moveRelocationNext(
DataRefImpl &Rel)
const = 0;
248 virtual uint64_t getRelocationOffset(
DataRefImpl Rel)
const = 0;
250 virtual uint64_t getRelocationType(
DataRefImpl Rel)
const = 0;
251 virtual void getRelocationTypeName(
DataRefImpl Rel,
262 return getCommonSymbolSizeImpl(Symb);
266 return std::vector<SectionRef>();
284 virtual uint8_t getBytesInAddress()
const = 0;
286 virtual StringRef getFileFormatName()
const = 0;
295 Triple makeTriple()
const;
297 virtual std::error_code
299 return std::error_code();
306 virtual bool isRelocatableObject()
const = 0;
375 return cast<ObjectFile>(
O);
381 : SectionPimpl(SectionP)
382 , OwningObject(Owner) {}
385 return SectionPimpl == Other.SectionPimpl;
389 return SectionPimpl != Other.SectionPimpl;
393 return SectionPimpl < Other.SectionPimpl;
475 : RelocationPimpl(RelocationP)
476 , OwningObject(Owner) {}
479 return RelocationPimpl == Other.RelocationPimpl;
503 return RelocationPimpl;
514 #endif // LLVM_OBJECT_OBJECTFILE_H const content_type & operator*() const
static uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAsmLayout &Layout)
Compute iterated dominance frontiers using a linear time algorithm.
Expected< StringRef > getName() const
uint64_t getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address...
uint64_t getOffset() const
bool operator!=(const SectionRef &Other) const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bool operator<(const DataRefImpl &a, const DataRefImpl &b)
virtual bool isSectionBSS(DataRefImpl Sec) const =0
This class is the base class for all object file types.
bool operator==(const RelocationRef &Other) const
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const =0
const uint8_t * base() const
virtual std::error_code getSectionName(DataRefImpl Sec, StringRef &Res) const =0
uint32_t getAlignment() const
Get the alignment of this symbol as the actual value (not log 2).
const ObjectFile * getObject() const
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const
virtual Expected< StringRef > getSymbolName(DataRefImpl Symb) const =0
virtual bool isSectionStripped(DataRefImpl Sec) const
relocation_iterator relocation_end() const
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const =0
void getTypeName(SmallVectorImpl< char > &Result) const
Get a string that represents the type of this relocation.
virtual std::error_code getBuildAttributes(ARMAttributeParser &Attributes) const
static uint32_t getAlignment(const MCSectionCOFF &Sec)
uint64_t getAddress() const
DataRefImpl getRawDataRefImpl() const
virtual std::error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const =0
This is a value type class that represents a single relocation in the list of relocations in the obje...
bool operator==(const SectionRef &Other) const
static StringRef getName(Value *V)
virtual uint64_t getSectionIndex(DataRefImpl Sec) const =0
Tagged union holding either a T or a Error.
bool operator!=(const DataRefImpl &a, const DataRefImpl &b)
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const =0
uint64_t getIndex() const
bool isCompressed() const
uint64_t getCommonSize() const
const ObjectFile * getObject() const
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const =0
section_iterator_range sections() const
virtual Expected< uint64_t > getStartAddress() const
virtual bool isSectionBitcode(DataRefImpl Sec) const
const ObjectFile * getObject() const
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Expected< section_iterator > getSection() const
Get section this symbol is defined in reference to.
virtual StringRef mapDebugSectionName(StringRef Name) const
Maps a debug section name to a standard DWARF section name.
virtual Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const =0
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
virtual void moveRelocationNext(DataRefImpl &Rel) const =0
The instances of the Type class are immutable: once they are created, they are never changed...
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
symbol_iterator(const basic_symbol_iterator &B)
virtual std::vector< SectionRef > dynamic_relocation_sections() const
relocation_iterator relocation_begin() const
static Expected< std::unique_ptr< ObjectFile > > createObjectFile(MemoryBufferRef Object)
bool operator<(const SectionRef &Other) const
section_iterator getRelocatedSection() const
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
DataRefImpl getRawDataRefImpl() const
Triple - Helper class for working with autoconf configuration names.
SymbolRef(const BasicSymbolRef &B)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
Expected< SymbolRef::Type > getType() const
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcode - Return true if the given bytes are the magic bytes for LLVM IR bitcode, either with or without a wrapper.
const SymbolicFile * getObject() const
std::error_code getName(StringRef &Result) const
virtual void setARMSubArch(Triple &TheTriple) const
const SymbolRef & operator*() const
virtual uint64_t getSectionAddress(DataRefImpl Sec) const =0
uint64_t getSymbolValue(DataRefImpl Symb) const
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const =0
std::error_code getContents(StringRef &Result) const
A range adaptor for a pair of iterators.
Manages the enabling and disabling of subtarget specific features.
virtual bool isSectionText(DataRefImpl Sec) const =0
This is a value type class that represents a single symbol in the list of symbols in the object file...
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
static bool classof(const Binary *v)
symbol_iterator getSymbol() const
symbol_iterator_range symbols() const
virtual void moveSectionNext(DataRefImpl &Sec) const =0
iterator_range< relocation_iterator > relocations() const
virtual bool isSectionData(DataRefImpl Sec) const =0
uint64_t getCommonSymbolSize(DataRefImpl Symb) const
This is a value type class that represents a single symbol in the list of symbols in the object file...
virtual section_iterator getRelocatedSection(DataRefImpl Sec) const
uint64_t getAlignment() const
Get the alignment of this section as the actual value (not log 2).
const SymbolRef * operator->() const
virtual bool isSectionCompressed(DataRefImpl Sec) const =0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual Expected< section_iterator > getSymbolSection(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...
StringRef - Represent a constant reference to a string, i.e.
static FeatureBitset getFeatures(StringRef CPU, StringRef FS, ArrayRef< SubtargetFeatureKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
virtual uint64_t getRelocationType(DataRefImpl Rel) const =0
DataRefImpl getRawDataRefImpl() const
This is a value type class that represents a single section in the list of sections in the object fil...
StringRef getSymbolName(CVSymbol Sym)
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...