16#define DEBUG_TYPE "orc"
24 return CPUType.takeError();
28 return CPUSubType.takeError();
36 return BinFile.takeError();
38 std::unique_ptr<object::MachOObjectFile> MachOFile;
39 if (isa<object::MachOObjectFile>(**BinFile))
40 MachOFile.reset(dyn_cast<object::MachOObjectFile>(BinFile->release()));
41 else if (
auto *MachOUni =
42 dyn_cast<object::MachOUniversalBinary>(BinFile->get())) {
43 for (
auto &O : MachOUni->objects()) {
44 if (O.getCPUType() == *CPUType &&
46 if (
auto Obj = O.getAsObjectFile())
47 MachOFile = std::move(*Obj);
49 return Obj.takeError();
54 return make_error<StringError>(
"MachO universal binary at " + Path +
55 " does not contain a slice for " +
59 return make_error<StringError>(
"File at " + Path +
" is not a MachO",
63 return make_error<StringError>(
"MachO at " + Path +
" is not a dylib",
67 for (
auto &
Sym : MachOFile->symbols()) {
71 return Name.takeError();
74 return std::move(Symbols);
88 return Tapi.takeError();
92 return CPUType.takeError();
96 return CPUSubType.takeError();
98 auto &IF = (*Tapi)->getInterfaceFile();
102 return Interface.takeError();
104 for (
auto *
Sym : (*Interface)->exports())
105 Symbols.insert(ES.
intern(
Sym->getName()));
122 return make_error<StringError>(
"Cannot get interface for " + Path +
123 " unrecognized file type",
Tagged union holding either a T or a Error.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
const std::string & str() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
An ExecutionSession represents a running JIT program.
const Triple & getTargetTriple() const
Return the triple for the executor.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
LLVM_ABI Expected< uint32_t > getCPUSubType(const Triple &T)
LLVM_ABI Architecture getArchitectureFromCpuType(uint32_t CPUType, uint32_t CPUSubType)
Convert a CPU Type and Subtype pair to an architecture slice.
LLVM_ABI Expected< uint32_t > getCPUType(const Triple &T)
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.
LLVM_ABI Expected< SymbolNameSet > getDylibInterfaceFromDylib(ExecutionSession &ES, Twine Path)
Returns a SymbolNameSet containing the exported symbols defined in the given dylib.
LLVM_ABI Expected< SymbolNameSet > getDylibInterface(ExecutionSession &ES, Twine Path)
Returns a SymbolNameSet containing the exported symbols defined in the relevant slice of the given fi...
LLVM_ABI Expected< SymbolNameSet > getDylibInterfaceFromTapiFile(ExecutionSession &ES, Twine Path)
Returns a SymbolNameSet containing the exported symbols defined in the relevant slice of the TapiUniv...
LLVM_ABI file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
@ macho_dynamically_linked_shared_lib
Mach-O dynlinked shared lib.
@ macho_universal_binary
Mach-O universal binary.
@ tapi_file
Text-based Dynamic Library Stub file.