LLVM: lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
21
22using namespace llvm;
24
25#define DEBUG_TYPE "dyld"
26
27namespace {
28
29class LoadedCOFFObjectInfo final
31 RuntimeDyld::LoadedObjectInfo> {
32public:
33 LoadedCOFFObjectInfo(
37
39 getObjectForDebug(const ObjectFile &Obj) const override {
41 }
42};
43}
44
45namespace llvm {
46
47std::unique_ptr
63
64std::unique_ptrRuntimeDyld::LoadedObjectInfo
67 return std::make_unique(*this, *ObjSectionToIDOrErr);
68 } else {
72 return nullptr;
73 }
74}
75
80
83 bool SetSectionIDMinus1) {
84 LLVM_DEBUG(dbgs() << "Getting DLLImport entry for " << Name << "... ");
86 "Not a DLLImport symbol?");
88 Reloc.SymbolName = Name.data();
89 auto [It, Inserted] = Stubs.try_emplace(Reloc);
90 if (!Inserted) {
92 return It->second;
93 }
94
95 assert(SectionID < Sections.size() && "SectionID out of range");
96 auto &Sec = Sections[SectionID];
97 auto EntryOffset = alignTo(Sec.getStubOffset(), PointerSize);
98 Sec.advanceStubOffset(EntryOffset + PointerSize - Sec.getStubOffset());
99 It->second = EntryOffset;
100
101 RelocationEntry RE(SectionID, EntryOffset, PointerReloc, 0, false,
103
104 if (SetSectionIDMinus1)
107
109 dbgs() << "Creating entry at "
110 << formatv("{0:x16} + {1:x8} ( {2:x16} )", Sec.getLoadAddress(),
111 EntryOffset, Sec.getLoadAddress() + EntryOffset)
112 << "\n";
113 });
114 return EntryOffset;
115}
116
118 return Obj.isCOFF();
119}
120
125 if (!TargetNameOrErr)
126 return false;
127
129}
130
131}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Tagged union holding either a T or a Error.
Symbol resolution interface.
RelocationEntry - used to represent relocations internally in the dynamic linker.
uint64_t getSymbolOffset(const SymbolRef &Sym)
Definition RuntimeDyldCOFF.cpp:76
static constexpr StringRef getImportSymbolPrefix()
std::unique_ptr< RuntimeDyld::LoadedObjectInfo > loadObject(const object::ObjectFile &Obj) override
Definition RuntimeDyldCOFF.cpp:65
static std::unique_ptr< RuntimeDyldCOFF > create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver)
Definition RuntimeDyldCOFF.cpp:48
bool relocationNeedsDLLImportStub(const RelocationRef &R) const override
Definition RuntimeDyldCOFF.cpp:121
bool isCompatibleFile(const object::ObjectFile &Obj) const override
Definition RuntimeDyldCOFF.cpp:117
uint64_t getDLLImportOffset(unsigned SectionID, StubMap &Stubs, StringRef Name, bool SetSectionIDMinus1=false)
Definition RuntimeDyldCOFF.cpp:81
std::map< RelocationValueRef, uintptr_t > StubMap
void addRelocationForSymbol(const RelocationEntry &RE, StringRef SymbolName)
JITSymbolResolver & Resolver
RuntimeDyld::MemoryManager & MemMgr
Expected< ObjSectionToIDMap > loadObjectImpl(const object::ObjectFile &Obj)
std::map< object::SectionRef, unsigned > ObjSectionToIDMap
StringRef - Represent a constant reference to a string, i.e.
This class is the base class for all object file types.
This is a value type class that represents a single relocation in the list of relocations in the obje...
This is a value type class that represents a single symbol in the list of symbols in the object file.
Expected< uint64_t > getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.