22using namespace object;
67 char **ErrorMessage) {
76 return wrap(ObjOrErr.
get().release());
80 auto Buf =
unwrap(BR)->getMemoryBufferRef();
82 Buf.getBuffer(), Buf.getBufferIdentifier(),
91 class BinaryTypeMapper final :
public Binary {
137 return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType(
unwrap(BR)->
getType());
143 char **ErrorMessage) {
144 auto universal = cast<MachOUniversalBinary>(
unwrap(BR));
146 universal->getMachOObjectForArch({Arch, ArchLen}));
151 return wrap(ObjOrErr.
get().release());
155 auto OF = cast<ObjectFile>(
unwrap(BR));
164 auto OF = cast<ObjectFile>(
unwrap(BR));
165 return (*
unwrap(SI) == OF->section_end()) ? 1 : 0;
169 auto OF = cast<ObjectFile>(
unwrap(BR));
170 auto symbols = OF->symbols();
171 if (symbols.begin() == symbols.end())
178 auto OF = cast<ObjectFile>(
unwrap(BR));
179 return (*
unwrap(SI) == OF->symbol_end()) ? 1 : 0;
184 std::unique_ptr<MemoryBuffer> Buf(
unwrap(MemBuf));
215 return (*
unwrap(SI) == OB->getBinary()->section_end()) ? 1 : 0;
231 *
unwrap(Sect) = *SecOrErr;
248 return (*
unwrap(SI) == OB->getBinary()->symbol_end()) ? 1 : 0;
260 return NameOrErr->data();
264 return (*
unwrap(SI))->getSize();
275 return (*
unwrap(SI))->getAddress();
295 return (*
unwrap(SI) == (*
unwrap(Section))->relocation_end()) ? 1 : 0;
327 return (*
unwrap(SI))->getCommonSize();
332 return (*
unwrap(RI))->getOffset();
341 return (*
unwrap(RI))->getType();
bbsections Prepares for basic block sections
This file defines counterparts of C library allocation functions defined in the namespace 'std'.
LLVMObjectFileRef wrap(const OwningBinary< ObjectFile > *OF)
OwningBinary< ObjectFile > * unwrap(LLVMObjectFileRef OF)
static StringRef getName(Value *V)
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
@ ID_MachOUniversalBinary
This class is the base class for all object file types.
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
A raw_ostream that writes to an std::string.
void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef SI)
void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI)
uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI)
LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef OF)
Deprecated: Use LLVMObjectFileCopySymbolIterator instead.
uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI)
LLVMBool LLVMObjectFileIsSymbolIteratorAtEnd(LLVMBinaryRef BR, LLVMSymbolIteratorRef SI)
Returns whether the given symbol iterator is at the end.
struct LLVMOpaqueSymbolIterator * LLVMSymbolIteratorRef
LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch(LLVMBinaryRef BR, const char *Arch, size_t ArchLen, char **ErrorMessage)
uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI)
uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI)
LLVMSymbolIteratorRef LLVMObjectFileCopySymbolIterator(LLVMBinaryRef BR)
Retrieve a copy of the symbol iterator for this object file.
uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI)
const char * LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI)
void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, LLVMSymbolIteratorRef Sym)
void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI)
LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef OF, LLVMSectionIteratorRef SI)
Deprecated: Use LLVMObjectFileIsSectionIteratorAtEnd instead.
void LLVMMoveToNextSection(LLVMSectionIteratorRef SI)
LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI)
const char * LLVMGetSymbolName(LLVMSymbolIteratorRef SI)
uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI)
void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef SI)
LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator(LLVMBinaryRef BR)
Retrieve a copy of the section iterator for this object file.
LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef OF)
Deprecated: Use LLVMObjectFileCopySectionIterator instead.
LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR)
Retrieve the specific type of a binary.
LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section)
void LLVMDisposeBinary(LLVMBinaryRef BR)
Dispose of a binary file.
struct LLVMOpaqueSectionIterator * LLVMSectionIteratorRef
const char * LLVMGetSectionName(LLVMSectionIteratorRef SI)
LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section, LLVMRelocationIteratorRef SI)
LLVMMemoryBufferRef LLVMBinaryCopyMemoryBuffer(LLVMBinaryRef BR)
Retrieves a copy of the memory buffer associated with this object file.
struct LLVMOpaqueRelocationIterator * LLVMRelocationIteratorRef
const char * LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI)
struct LLVMOpaqueObjectFile * LLVMObjectFileRef
Deprecated: Use LLVMBinaryRef instead.
LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef OF, LLVMSymbolIteratorRef SI)
Deprecated: Use LLVMObjectFileIsSymbolIteratorAtEnd instead.
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf)
Deprecated: Use LLVMCreateBinary instead.
LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI, LLVMSymbolIteratorRef Sym)
void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile)
Deprecated: Use LLVMDisposeBinary instead.
const char * LLVMGetSectionContents(LLVMSectionIteratorRef SI)
LLVMBinaryRef LLVMCreateBinary(LLVMMemoryBufferRef MemBuf, LLVMContextRef Context, char **ErrorMessage)
Create a binary file from the given memory buffer.
void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI)
LLVMBool LLVMObjectFileIsSectionIteratorAtEnd(LLVMBinaryRef BR, LLVMSectionIteratorRef SI)
Returns whether the given section iterator is at the end.
@ LLVMBinaryTypeIR
LLVM IR.
@ LLVMBinaryTypeDXcontainer
DirectX Binary Container.
@ LLVMBinaryTypeELF64B
ELF 64-bit, big endian.
@ LLVMBinaryTypeArchive
Archive file.
@ LLVMBinaryTypeMachO32B
MachO 32-bit, big endian.
@ LLVMBinaryTypeWasm
Web Assembly.
@ LLVMBinaryTypeELF64L
ELF 64-bit, little endian.
@ LLVMBinaryTypeWinRes
Windows resource (.res) file.
@ LLVMBinaryTypeMachOUniversalBinary
Mach-O Universal Binary file.
@ LLVMBinaryTypeMachO64B
MachO 64-bit, big endian.
@ LLVMBinaryTypeCOFF
COFF Object file.
@ LLVMBinaryTypeCOFFImportFile
COFF Import file.
@ LLVMBinaryTypeELF32B
ELF 32-bit, big endian.
@ LLVMBinaryTypeELF32L
ELF 32-bit, little endian.
@ LLVMBinaryTypeMachO32L
MachO 32-bit, little endian.
@ LLVMBinaryTypeMachO64L
MachO 64-bit, little endian.
@ LLVMBinaryTypeOffload
Offloading fatbinary.
struct LLVMOpaqueBinary * LLVMBinaryRef
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
content_iterator< SectionRef > section_iterator
content_iterator< RelocationRef > relocation_iterator
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.
LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
LLVM_GET_TYPE_NAME_CONSTEXPR StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
OutputIt copy(R &&Range, OutputIt Out)
const char * toString(DWARFSectionKind Kind)
void consumeError(Error Err)
Consume a Error without doing anything.