LLVM: lib/Object/IRObjectFile.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

19using namespace llvm;

20using namespace object;

21

22namespace llvm {

25}

26

28 std::vector<std::unique_ptr> Mods)

30 for (auto &M : this->Mods)

31 SymTab.addModule(M.get());

32}

33

35

38}

39

42}

43

47}

48

51}

52

55 Ret.p = reinterpret_cast<uintptr_t>(SymTab.symbols().data());

57}

58

61 Ret.p = reinterpret_cast<uintptr_t>(SymTab.symbols().data() +

64}

65

67

68

69 return Mods[0]->getTargetTriple();

70}

71

75 if (Sec.isBitcode()) {

77 if (!Contents)

79 if (Contents->size() <= 1)

82 }

83 }

84

86}

87

91 switch (Type) {

93 return Object;

100 if (!ObjFile)

103 }

104 default:

106 }

107}

108

112 if (!BCOrErr)

114

117 if (!BMsOrErr)

119

120 std::vector<std::unique_ptr> Mods;

121 for (auto BM : *BMsOrErr) {

123 BM.getLazyModule(Context, true,

124 false);

125 if (!MOrErr)

127

128 Mods.push_back(std::move(*MOrErr));

129 }

130

131 return std::unique_ptr(

132 new IRObjectFile(*BCOrErr, std::move(Mods)));

133}

134

139 if (!BCOrErr)

141

143 if (!BFCOrErr)

145

147 if (!FCOrErr)

149

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);

154 return std::move(F);

155}

static ModuleSymbolTable::Symbol getSym(DataRefImpl &Symb)

Module.h This file contains the declarations for the Module class.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

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.

This is an important class for using LLVM in a threaded context.

void printSymbolName(raw_ostream &OS, Symbol S) const

PointerUnion< GlobalValue *, AsmSymbol * > Symbol

uint32_t getSymbolFlags(Symbol S) const

ArrayRef< Symbol > symbols() const

A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...

StringRef - Represent a constant reference to a string, i.e.

The instances of the Type class are immutable: once they are created, they are never changed.

This is a value type class that represents a single symbol in the list of symbols in the object file.

StringRef getFileName() const

Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override

Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override

StringRef getTargetTriple() const

basic_symbol_iterator symbol_begin() const override

static Expected< MemoryBufferRef > findBitcodeInObject(const ObjectFile &Obj)

Finds and returns bitcode embedded in the given object file, or an error code if not found.

basic_symbol_iterator symbol_end() const override

void moveSymbolNext(DataRefImpl &Symb) const override

static Expected< MemoryBufferRef > findBitcodeInMemBuffer(MemoryBufferRef Object)

Finds and returns bitcode in the given memory buffer (which may be either a bitcode file or a native ...

static Expected< std::unique_ptr< IRObjectFile > > create(MemoryBufferRef Object, LLVMContext &Context)

This class is the base class for all object file types.

section_iterator_range sections() const

static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)

This is a value type class that represents a single section in the list of sections in the object fil...

This class implements an extremely fast bulk output stream that can only output to a stream.

Expected< FileContents > readBitcode(const BitcodeFileContents &BFC)

Reads the contents of a bitcode file, creating its irsymtab if necessary.

Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)

Reads a bitcode file, creating its irsymtab if necessary.

@ bitcode_section_not_found

content_iterator< BasicSymbolRef > basic_symbol_iterator

This is an optimization pass for GlobalISel generic memory operations.

file_magic identify_magic(StringRef magic)

Identify the type of a binary file based on how magical it is.

Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)

Returns the contents of a bitcode file.

Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)

Returns a list of modules in the specified bitcode buffer.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Error errorCodeToError(std::error_code EC)

Helper for converting an std::error_code to a Error.

Implement std::hash so that hash_code can be used in STL containers.

file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...

@ elf_relocatable

ELF Relocatable object file.

@ wasm_object

WebAssembly Object file.

@ macho_object

Mach-O Object file.

@ coff_object

COFF object file.

The contents of a bitcode file and its irsymtab.