30 std::vector<std::unique_ptr<Module>> Mods)
31 : SymbolicFile(
Binary::ID_IR, Object), Mods(
std::move(Mods)) {
32 for (
auto &M : this->Mods)
33 SymTab.addModule(
M.get());
36 IRObjectFile::~IRObjectFile() {}
46 std::error_code IRObjectFile::printSymbolName(
raw_ostream &OS,
48 SymTab.printSymbolName(OS,
getSym(Symb));
49 return std::error_code();
53 return SymTab.getSymbolFlags(
getSym(Symb));
58 Ret.
p =
reinterpret_cast<uintptr_t
>(SymTab.symbols().data());
64 Ret.
p =
reinterpret_cast<uintptr_t
>(SymTab.symbols().data() +
65 SymTab.symbols().size());
72 return Mods[0]->getTargetTriple();
76 IRObjectFile::findBitcodeInObject(
const ObjectFile &Obj) {
78 if (Sec.isBitcode()) {
80 if (std::error_code EC = Sec.getContents(SecContents))
95 case file_magic::elf_relocatable:
96 case file_magic::macho_object:
97 case file_magic::coff_object: {
99 ObjectFile::createObjectFile(Object, Type);
102 return findBitcodeInObject(*ObjFile->
get());
120 std::vector<std::unique_ptr<Module>> Mods;
121 for (
auto BM : *BMsOrErr) {
123 BM.getLazyModule(Context,
true,
128 Mods.push_back(std::move(*MOrErr));
131 return std::unique_ptr<IRObjectFile>(
138 IRObjectFile::findBitcodeInMemBuffer(MBRef);
150 F.
Mods = std::move(BFCOrErr->Mods);
151 F.
Symtab = std::move(FCOrErr->Symtab);
152 F.
Strtab = std::move(FCOrErr->Strtab);
153 F.
TheReader = std::move(FCOrErr->TheReader);
This class represents lattice values for constants.
StringRef getFileName() const
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.
StringRef getBuffer() const
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.
section_iterator_range sections() const
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.
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.
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)...