22using namespace object;
67 char **ErrorMessage) {
68 auto maybeContext = Context ?
unwrap(Context) :
nullptr;
76 return wrap(ObjOrErr.
get().release());
80 auto Buf =
unwrap(BR)->getMemoryBufferRef();
82 Buf.getBuffer(), Buf.getBufferIdentifier(),
91 class BinaryTypeMapper final :
public Binary {
135 return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType(
unwrap(BR)->
getType());
141 char **ErrorMessage) {
142 auto universal = cast<MachOUniversalBinary>(
unwrap(BR));
144 universal->getMachOObjectForArch({Arch, ArchLen}));
149 return wrap(ObjOrErr.
get().release());
153 auto OF = cast<ObjectFile>(
unwrap(BR));
162 auto OF = cast<ObjectFile>(
unwrap(BR));
163 return (*
unwrap(SI) == OF->section_end()) ? 1 : 0;
167 auto OF = cast<ObjectFile>(
unwrap(BR));
168 auto symbols = OF->symbols();
169 if (symbols.begin() == symbols.end())
176 auto OF = cast<ObjectFile>(
unwrap(BR));
177 return (*
unwrap(SI) == OF->symbol_end()) ? 1 : 0;
182 std::unique_ptr<MemoryBuffer> Buf(
unwrap(MemBuf));
185 std::unique_ptr<ObjectFile> Obj;
214 return (*
unwrap(SI) == OB->getBinary()->section_end()) ? 1 : 0;
230 *
unwrap(Sect) = *SecOrErr;
247 return (*
unwrap(SI) == OB->getBinary()->symbol_end()) ? 1 : 0;
259 return NameOrErr->data();
263 return (*
unwrap(SI))->getSize();
274 return (*
unwrap(SI))->getAddress();
294 return (*
unwrap(SI) == (*
unwrap(Section))->relocation_end()) ? 1 : 0;
326 return (*
unwrap(SI))->getCommonSize();
331 return (*
unwrap(RI))->getOffset();
340 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)
const Value * getAddress(const DbgVariableIntrinsic *DVI)
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.
uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI)
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf)
Deprecated: Use LLVMCreateBinary instead.
LLVMSymbolIteratorRef LLVMObjectFileCopySymbolIterator(LLVMBinaryRef BR)
Retrieve a copy of the symbol iterator for this object file.
LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section, LLVMRelocationIteratorRef SI)
struct LLVMOpaqueSymbolIterator * LLVMSymbolIteratorRef
void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef SI)
void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI)
const char * LLVMGetSectionContents(LLVMSectionIteratorRef SI)
const char * LLVMGetSectionName(LLVMSectionIteratorRef SI)
uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI)
uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI)
const char * LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI)
LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef OF, LLVMSectionIteratorRef SI)
Deprecated: Use LLVMObjectFileIsSectionIteratorAtEnd instead.
uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI)
void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI)
LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef OF)
Deprecated: Use LLVMObjectFileCopySymbolIterator instead.
LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef OF)
Deprecated: Use LLVMObjectFileCopySectionIterator instead.
uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI)
LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef OF, LLVMSymbolIteratorRef SI)
Deprecated: Use LLVMObjectFileIsSymbolIteratorAtEnd instead.
LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR)
Retrieve the specific type of a binary.
LLVMBool LLVMObjectFileIsSectionIteratorAtEnd(LLVMBinaryRef BR, LLVMSectionIteratorRef SI)
Returns whether the given section iterator is at the end.
void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI)
LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section)
struct LLVMOpaqueSectionIterator * LLVMSectionIteratorRef
LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch(LLVMBinaryRef BR, const char *Arch, size_t ArchLen, char **ErrorMessage)
void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, LLVMSymbolIteratorRef Sym)
void LLVMDisposeBinary(LLVMBinaryRef BR)
Dispose of a binary file.
LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator(LLVMBinaryRef BR)
Retrieve a copy of the section iterator for this object file.
void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef SI)
LLVMBinaryRef LLVMCreateBinary(LLVMMemoryBufferRef MemBuf, LLVMContextRef Context, char **ErrorMessage)
Create a binary file from the given memory buffer.
LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI)
void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile)
Deprecated: Use LLVMDisposeBinary instead.
LLVMBool LLVMObjectFileIsSymbolIteratorAtEnd(LLVMBinaryRef BR, LLVMSymbolIteratorRef SI)
Returns whether the given symbol iterator is at the end.
const char * LLVMGetSymbolName(LLVMSymbolIteratorRef SI)
struct LLVMOpaqueRelocationIterator * LLVMRelocationIteratorRef
struct LLVMOpaqueObjectFile * LLVMObjectFileRef
Deprecated: Use LLVMBinaryRef instead.
LLVMMemoryBufferRef LLVMBinaryCopyMemoryBuffer(LLVMBinaryRef BR)
Retrieves a copy of the memory buffer associated with this object file.
void LLVMMoveToNextSection(LLVMSectionIteratorRef SI)
LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI, LLVMSymbolIteratorRef Sym)
const char * LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI)
uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI)
@ LLVMBinaryTypeIR
LLVM IR.
@ 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.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
content_iterator< SectionRef > section_iterator
content_iterator< RelocationRef > relocation_iterator
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.
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
OutputIt copy(R &&Range, OutputIt Out)
void consumeError(Error Err)
Consume a Error without doing anything.