13#ifndef LLVM_OBJECT_BINARY_H
14#define LLVM_OBJECT_BINARY_H
80 static inline unsigned int getELFType(
bool isLE,
bool is64Bits) {
82 return is64Bits ? ID_ELF64L : ID_ELF32L;
84 return is64Bits ? ID_ELF64B : ID_ELF32B;
89 return is64Bits ? ID_MachO64L : ID_MachO32L;
91 return is64Bits ? ID_MachO64B : ID_MachO32B;
110 return TypeID > ID_StartObjects &&
TypeID < ID_EndObjects;
114 return isIR() || isObject() || isCOFFImportFile() || isTapiFile();
120 return TypeID == ID_MachOUniversalBinary;
144 return TypeID == ID_COFFImportFile;
171 return Triple::MachO;
176 return Triple::UnknownObjectFormat;
182 Addr +
Size >
reinterpret_cast<uintptr_t
>(M.getBufferEnd()) ||
183 Addr <
reinterpret_cast<uintptr_t
>(M.getBufferStart())) {
186 return Error::success();
198 bool InitContent =
true);
201 std::unique_ptr<T> Bin;
202 std::unique_ptr<MemoryBuffer> Buf;
206 OwningBinary(std::unique_ptr<T> Bin, std::unique_ptr<MemoryBuffer> Buf);
210 std::pair<std::unique_ptr<T>, std::unique_ptr<MemoryBuffer>>
takeBinary();
218 std::unique_ptr<MemoryBuffer> Buf)
230 Buf = std::move(
Other.Buf);
235std::pair<std::unique_ptr<T>, std::unique_ptr<MemoryBuffer>>
237 return std::make_pair(std::move(
Bin), std::move(Buf));
250 bool InitContent =
true);
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
static Expected< StringRef > getFileName(const DebugStringTableSubsectionRef &Strings, const DebugChecksumsSubsectionRef &Checksums, uint32_t FileID)
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
This is an important class for using LLVM in a threaded context.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isTapiUniversal() const
@ ID_MachOUniversalBinary
bool isMachOUniversalBinary() const
static unsigned int getELFType(bool isLE, bool is64Bits)
Triple::ObjectFormatType getTripleObjectFormat() const
bool isCOFFImportFile() const
unsigned int getType() const
bool isLittleEndian() const
virtual Error initContent()
bool isOffloadFile() const
static unsigned int getMachOType(bool isLE, bool is64Bits)
bool isDXContainer() const
Binary(const Binary &other)=delete
static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
const T * getBinary() const
OwningBinary< T > & operator=(OwningBinary< T > &&Other)
std::pair< std::unique_ptr< T >, std::unique_ptr< MemoryBuffer > > takeBinary()
OwningBinary(std::unique_ptr< T > Bin, std::unique_ptr< MemoryBuffer > Buf)
OwningBinary(OwningBinary< T > &&Other)
struct LLVMOpaqueBinary * LLVMBinaryRef
LLVM_ABI Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Implement std::hash so that hash_code can be used in STL containers.