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

39

43

45 SymTab.printSymbolName(OS, getSym(Symb));

47}

48

50 return SymTab.getSymbolFlags(getSym(Symb));

51}

52

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

57}

58

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

62 SymTab.symbols().size());

64}

65

67

68

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

70}

71

74 for (const SectionRef &Sec : Obj.sections()) {

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)

Definition IRObjectFile.cpp:36

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.

PointerUnion< GlobalValue *, AsmSymbol * > Symbol

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

std::string str() const

str - Get the contents as an std::string.

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.

Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override

Definition IRObjectFile.cpp:49

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

Definition IRObjectFile.cpp:44

StringRef getTargetTriple() const

Definition IRObjectFile.cpp:66

basic_symbol_iterator symbol_begin() const override

Definition IRObjectFile.cpp:53

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

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

Definition IRObjectFile.cpp:73

basic_symbol_iterator symbol_end() const override

Definition IRObjectFile.cpp:59

void moveSymbolNext(DataRefImpl &Symb) const override

Definition IRObjectFile.cpp:40

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 ...

Definition IRObjectFile.cpp:89

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

Definition IRObjectFile.cpp:110

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

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.

LLVM_ABI Expected< FileContents > readBitcode(const BitcodeFileContents &BFC)

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

LLVM_ABI Expected< IRSymtabFile > readIRSymtab(MemoryBufferRef MBRef)

Reads a bitcode file, creating its irsymtab if necessary.

Definition IRObjectFile.cpp:135

content_iterator< BasicSymbolRef > basic_symbol_iterator

@ bitcode_section_not_found

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI file_magic identify_magic(StringRef magic)

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

LLVM_ABI Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)

Returns the contents of a bitcode file.

LLVM_ABI 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.

LLVM_ABI 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.