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;
101 std::error_code getContents(
StringRef &Result)
const;
106 bool isCompressed()
const;
113 bool isVirtual()
const;
115 bool isStripped()
const;
120 bool isBerkeleyText()
const;
124 bool isBerkeleyData()
const;
131 return make_range(relocation_begin(), relocation_end());
167 uint64_t getValue()
const;
171 uint64_t getCommonSize()
const;
203 virtual void anchor();
209 return reinterpret_cast<const uint8_t *
>(
Data.getBufferStart());
226 virtual uint64_t getSymbolValueImpl(
DataRefImpl Symb)
const = 0;
228 virtual uint64_t getCommonSymbolSizeImpl(
DataRefImpl Symb)
const = 0;
236 virtual void moveSectionNext(
DataRefImpl &Sec)
const = 0;
237 virtual std::error_code getSectionName(
DataRefImpl Sec,
239 virtual uint64_t getSectionAddress(
DataRefImpl Sec)
const = 0;
240 virtual uint64_t getSectionIndex(
DataRefImpl Sec)
const = 0;
241 virtual uint64_t getSectionSize(
DataRefImpl Sec)
const = 0;
242 virtual std::error_code getSectionContents(
DataRefImpl Sec,
244 virtual uint64_t getSectionAlignment(
DataRefImpl Sec)
const = 0;
245 virtual bool isSectionCompressed(
DataRefImpl Sec)
const = 0;
246 virtual bool isSectionText(
DataRefImpl Sec)
const = 0;
247 virtual bool isSectionData(
DataRefImpl Sec)
const = 0;
248 virtual bool isSectionBSS(
DataRefImpl Sec)
const = 0;
250 virtual bool isSectionVirtual(
DataRefImpl Sec)
const = 0;
251 virtual bool isSectionBitcode(
DataRefImpl Sec)
const;
252 virtual bool isSectionStripped(
DataRefImpl Sec)
const;
253 virtual bool isBerkeleyText(
DataRefImpl Sec)
const;
254 virtual bool isBerkeleyData(
DataRefImpl Sec)
const;
261 virtual void moveRelocationNext(
DataRefImpl &Rel)
const = 0;
262 virtual uint64_t getRelocationOffset(
DataRefImpl Rel)
const = 0;
264 virtual uint64_t getRelocationType(
DataRefImpl Rel)
const = 0;
265 virtual void getRelocationTypeName(
DataRefImpl Rel,
276 return getCommonSymbolSizeImpl(Symb);
280 return std::vector<SectionRef>();
298 virtual uint8_t getBytesInAddress()
const = 0;
300 virtual StringRef getFileFormatName()
const = 0;
309 Triple makeTriple()
const;
311 virtual std::error_code
313 return std::error_code();
320 virtual bool isRelocatableObject()
const = 0;
389 return cast<ObjectFile>(
O);
395 : SectionPimpl(SectionP)
396 , OwningObject(Owner) {}
399 return SectionPimpl == Other.SectionPimpl;
403 return SectionPimpl != Other.SectionPimpl;
407 return SectionPimpl < Other.SectionPimpl;
497 : RelocationPimpl(RelocationP)
498 , OwningObject(Owner) {}
501 return RelocationPimpl == Other.RelocationPimpl;
525 return RelocationPimpl;
536 #endif // LLVM_OBJECT_OBJECTFILE_H const content_type & operator*() const
static uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAsmLayout &Layout)
virtual bool isBerkeleyData(DataRefImpl Sec) const
This class represents lattice values for constants.
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)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
uint64_t getAddress() const
DataRefImpl getRawDataRefImpl() const
static StringRef getSymbolName(SymbolKind SymKind)
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)
bool isText() const
Whether this section contains instructions.
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
bool isData() const
Whether this section contains data, not instructions.
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.
bool isBerkeleyText() const
Whether this section will be placed in the text segment, according to the Berkeley size format...
virtual Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const =0
bool isBSS() const
Whether this section contains BSS uninitialized data.
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 isBerkeleyText(DataRefImpl Sec) 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)
bool isBerkeleyData() const
Whether this section will be placed in the data segment, according to the Berkeley size format...
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...
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...