24 return reinterpret_cast<OwningBinary<ObjectFile> *
>(OF);
29 const_cast<OwningBinary<ObjectFile> *
>(OF));
43 return reinterpret_cast<symbol_iterator*
>(
SI);
49 (
const_cast<symbol_iterator*
>(
SI));
66 char **ErrorMessage) {
67 auto maybeContext = Context ?
unwrap(Context) :
nullptr;
75 return wrap(ObjOrErr.
get().release());
79 auto Buf =
unwrap(BR)->getMemoryBufferRef();
81 Buf.getBuffer(), Buf.getBufferIdentifier(),
90 class BinaryTypeMapper final :
public Binary {
96 case ID_MachOUniversalBinary:
98 case ID_COFFImportFile:
124 case ID_StartObjects:
132 return BinaryTypeMapper::mapBinaryTypeToLLVMBinaryType(
unwrap(BR)->
getType());
138 char **ErrorMessage) {
139 auto universal = cast<MachOUniversalBinary>(
unwrap(BR));
141 universal->getMachOObjectForArch({Arch, ArchLen}));
143 *ErrorMessage = strdup(
toString(ObjOrErr.takeError()).
c_str());
146 return wrap(ObjOrErr.get().release());
150 auto OF = cast<ObjectFile>(
unwrap(BR));
151 auto sections = OF->sections();
152 if (sections.begin() == sections.end())
159 auto OF = cast<ObjectFile>(
unwrap(BR));
160 return (*
unwrap(SI) == OF->section_end()) ? 1 : 0;
164 auto OF = cast<ObjectFile>(
unwrap(BR));
165 auto symbols = OF->symbols();
166 if (symbols.begin() == symbols.end())
168 return wrap(
new symbol_iterator(symbols.begin()));
173 auto OF = cast<ObjectFile>(
unwrap(BR));
174 return (*
unwrap(SI) == OF->symbol_end()) ? 1 : 0;
179 std::unique_ptr<MemoryBuffer> Buf(
unwrap(MemBuf));
182 std::unique_ptr<ObjectFile> Obj;
189 auto *
Ret =
new OwningBinary<ObjectFile>(std::move(ObjOrErr.
get()), std::move(Buf));
194 delete unwrap(ObjectFile);
199 OwningBinary<ObjectFile> *
OB =
unwrap(OF);
210 OwningBinary<ObjectFile> *
OB =
unwrap(OF);
211 return (*
unwrap(SI) == OB->getBinary()->section_end()) ? 1 : 0;
228 *
unwrap(Sect) = *SecOrErr;
233 OwningBinary<ObjectFile> *
OB =
unwrap(OF);
234 symbol_iterator
SI = OB->getBinary()->symbol_begin();
235 return wrap(
new symbol_iterator(SI));
244 OwningBinary<ObjectFile> *
OB =
unwrap(OF);
245 return (*
unwrap(SI) == OB->getBinary()->symbol_end()) ? 1 : 0;
257 return NameOrErr->data();
261 return (*
unwrap(SI))->getSize();
272 return (*
unwrap(SI))->getAddress();
292 return (*
unwrap(SI) == (*
unwrap(Section))->relocation_end()) ? 1 : 0;
326 return (*
unwrap(SI))->getCommonSize();
331 return (*
unwrap(RI))->getOffset();
335 symbol_iterator ret = (*
unwrap(RI))->getSymbol();
336 return wrap(
new symbol_iterator(ret));
340 return (*
unwrap(RI))->getType();
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
LLVMBinaryType LLVMBinaryGetType(LLVMBinaryRef BR)
Retrieve the specific type of a binary.
LLVMBinaryRef LLVMMachOUniversalBinaryCopyObjectForArch(LLVMBinaryRef BR, const char *Arch, size_t ArchLen, char **ErrorMessage)
uint64_t LLVMGetSectionAddress(LLVMSectionIteratorRef SI)
MachO 64-bit, big endian.
ELF 64-bit, little endian.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
LLVMBool LLVMGetSectionContainsSymbol(LLVMSectionIteratorRef SI, LLVMSymbolIteratorRef Sym)
LLVMBool LLVMObjectFileIsSectionIteratorAtEnd(LLVMBinaryRef BR, LLVMSectionIteratorRef SI)
Returns whether the given section iterator is at the end.
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf)
Deprecated: Use LLVMCreateBinary instead.
MachO 32-bit, little endian.
Error takeError()
Take ownership of the stored error.
const char * LLVMGetSectionContents(LLVMSectionIteratorRef SI)
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr)
Create a Binary from Source, autodetecting the file type.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Attribute unwrap(LLVMAttributeRef Attr)
LLVMBool LLVMIsRelocationIteratorAtEnd(LLVMSectionIteratorRef Section, LLVMRelocationIteratorRef SI)
static StringRef getName(Value *V)
Tagged union holding either a T or a Error.
void LLVMDisposeSymbolIterator(LLVMSymbolIteratorRef SI)
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
void LLVMMoveToContainingSection(LLVMSectionIteratorRef Sect, LLVMSymbolIteratorRef Sym)
LLVMBinaryRef LLVMCreateBinary(LLVMMemoryBufferRef MemBuf, LLVMContextRef Context, char **ErrorMessage)
Create a binary file from the given memory buffer.
content_iterator< SectionRef > section_iterator
struct LLVMOpaqueSectionIterator * LLVMSectionIteratorRef
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI)
struct LLVMOpaqueBinary * LLVMBinaryRef
void LLVMMoveToNextRelocation(LLVMRelocationIteratorRef SI)
LLVMSymbolIteratorRef LLVMGetRelocationSymbol(LLVMRelocationIteratorRef RI)
Control flow instructions. These all have token chains.
void LLVMDisposeBinary(LLVMBinaryRef BR)
Dispose of a binary file.
uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
struct LLVMOpaqueSymbolIterator * LLVMSymbolIteratorRef
LLVMBool LLVMObjectFileIsSymbolIteratorAtEnd(LLVMBinaryRef BR, LLVMSymbolIteratorRef SI)
Returns whether the given symbol iterator is at the end.
struct LLVMOpaqueObjectFile * LLVMObjectFileRef
Deprecated: Use LLVMBinaryRef instead.
Windows resource (.res) file.
LLVMBool LLVMIsSectionIteratorAtEnd(LLVMObjectFileRef OF, LLVMSectionIteratorRef SI)
Deprecated: Use LLVMObjectFileIsSectionIteratorAtEnd instead.
void consumeError(Error Err)
Consume a Error without doing anything.
static wasm::ValType getType(const TargetRegisterClass *RC)
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVMSymbolIteratorRef LLVMGetSymbols(LLVMObjectFileRef OF)
Deprecated: Use LLVMObjectFileCopySymbolIterator instead.
ELF 32-bit, little endian.
LLVMRelocationIteratorRef LLVMGetRelocations(LLVMSectionIteratorRef Section)
const char * LLVMGetSectionName(LLVMSectionIteratorRef SI)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
LLVMSymbolIteratorRef LLVMObjectFileCopySymbolIterator(LLVMBinaryRef BR)
Retrieve a copy of the symbol iterator for this object file.
const char * LLVMGetSymbolName(LLVMSymbolIteratorRef SI)
MachO 64-bit, little endian.
reference get()
Returns a reference to the stored T value.
void LLVMDisposeRelocationIterator(LLVMRelocationIteratorRef SI)
LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef OF)
Deprecated: Use LLVMObjectFileCopySectionIterator instead.
Mach-O Universal Binary file.
LLVMAttributeRef wrap(Attribute Attr)
void LLVMMoveToNextSymbol(LLVMSymbolIteratorRef SI)
uint64_t LLVMGetSymbolAddress(LLVMSymbolIteratorRef SI)
const char * LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI)
struct LLVMOpaqueRelocationIterator * LLVMRelocationIteratorRef
uint64_t LLVMGetRelocationOffset(LLVMRelocationIteratorRef RI)
LLVMMemoryBufferRef LLVMBinaryCopyMemoryBuffer(LLVMBinaryRef BR)
Retrieves a copy of the memory buffer associated with this object file.
uint64_t LLVMGetRelocationType(LLVMRelocationIteratorRef RI)
void LLVMDisposeObjectFile(LLVMObjectFileRef ObjectFile)
Deprecated: Use LLVMDisposeBinary instead.
A raw_ostream that writes to an std::string.
MachO 32-bit, big endian.
LLVMBool LLVMIsSymbolIteratorAtEnd(LLVMObjectFileRef OF, LLVMSymbolIteratorRef SI)
Deprecated: Use LLVMObjectFileIsSymbolIteratorAtEnd instead.
content_iterator< RelocationRef > relocation_iterator
uint64_t LLVMGetSymbolSize(LLVMSymbolIteratorRef SI)
const char * LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI)
LLVMSectionIteratorRef LLVMObjectFileCopySectionIterator(LLVMBinaryRef BR)
Retrieve a copy of the section iterator for this object file.
OutputIt copy(R &&Range, OutputIt Out)
void LLVMMoveToNextSection(LLVMSectionIteratorRef SI)