37 using namespace object;
40 std::vector<std::unique_ptr<Module>> Mods)
41 : SymbolicFile(Binary::ID_IR, Object), Mods(std::move(Mods)) {
42 for (
auto &M : this->Mods)
43 SymTab.addModule(M.get());
46 IRObjectFile::~IRObjectFile() {}
56 std::error_code IRObjectFile::printSymbolName(
raw_ostream &OS,
58 SymTab.printSymbolName(OS,
getSym(Symb));
59 return std::error_code();
63 return SymTab.getSymbolFlags(
getSym(Symb));
68 Ret.
p =
reinterpret_cast<uintptr_t
>(SymTab.symbols().data());
74 Ret.
p =
reinterpret_cast<uintptr_t
>(SymTab.symbols().data() +
75 SymTab.symbols().size());
82 return Mods[0]->getTargetTriple();
87 if (Sec.isBitcode()) {
89 if (std::error_code EC = Sec.getContents(SecContents))
95 return object_error::bitcode_section_not_found;
103 case file_magic::elf_relocatable:
104 case file_magic::macho_object:
105 case file_magic::coff_object: {
107 ObjectFile::createObjectFile(Object, Type);
110 return findBitcodeInObject(*ObjFile->
get());
113 return object_error::invalid_file_type;
126 return BMsOrErr.takeError();
128 std::vector<std::unique_ptr<Module>> Mods;
129 for (
auto BM : *BMsOrErr) {
131 BM.getLazyModule(Context,
true,
136 Mods.push_back(std::move(*MOrErr));
139 return std::unique_ptr<IRObjectFile>(
146 IRObjectFile::findBitcodeInMemBuffer(MBRef);
152 return BFCOrErr.takeError();
158 F.
Mods = std::move(BFCOrErr->Mods);
159 F.
Symtab = std::move(FCOrErr->Symtab);
160 F.
Strtab = std::move(FCOrErr->Strtab);
161 F.
TheReader = std::move(FCOrErr->TheReader);
std::error_code getError() const
Represents either an error or a value T.
This class is the base class for all object file types.
irsymtab::Reader TheReader
Error takeError()
Take ownership of the stored error.
static ModuleSymbolTable::Symbol getSym(DataRefImpl &Symb)
Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)
Returns a list of modules in the specified bitcode buffer.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Tagged union holding either a T or a Error.
The contents of a bitcode file and its irsymtab.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
std::vector< BitcodeModule > Mods
Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)
Returns the contents of a bitcode file.
section_iterator_range sections() const
StringRef getFileName() const
StringRef getBuffer() const
Module.h This file contains the declarations for the Module class.
SmallVector< char, 0 > Strtab
reference get()
Returns a reference to the stored T value.
Expected< FileContents > readBitcode(const BitcodeFileContents &BFC)
Reads the contents of a bitcode file, creating its irsymtab if necessary.
content_iterator< BasicSymbolRef > basic_symbol_iterator
This is a value type class that represents a single symbol in the list of symbols in the object file...
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)
Reads a bitcode file, creating its irsymtab if necessary.
std::error_code errorToErrorCode(Error Err)
Helper for converting an ECError to a std::error_code.
SmallVector< char, 0 > Symtab
This is a value type class that represents a single section in the list of sections in the object fil...
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...