xref: /freebsd/contrib/llvm-project/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.h (revision e25152834cdf3b353892835a4f3b157e066a8ed4)
10b57cec5SDimitry Andric //===-- RuntimeDyldCOFF.h - Run-time dynamic linker for MC-JIT ---*- C++ -*-==//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // COFF support for MC-JIT runtime dynamic linker.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_RUNTIME_DYLD_COFF_H
140b57cec5SDimitry Andric #define LLVM_RUNTIME_DYLD_COFF_H
150b57cec5SDimitry Andric 
160b57cec5SDimitry Andric #include "RuntimeDyldImpl.h"
170b57cec5SDimitry Andric 
180b57cec5SDimitry Andric #define DEBUG_TYPE "dyld"
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric using namespace llvm;
210b57cec5SDimitry Andric 
220b57cec5SDimitry Andric namespace llvm {
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric // Common base class for COFF dynamic linker support.
250b57cec5SDimitry Andric // Concrete subclasses for each target can be found in ./Targets.
260b57cec5SDimitry Andric class RuntimeDyldCOFF : public RuntimeDyldImpl {
270b57cec5SDimitry Andric 
280b57cec5SDimitry Andric public:
290b57cec5SDimitry Andric   std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
300b57cec5SDimitry Andric   loadObject(const object::ObjectFile &Obj) override;
310b57cec5SDimitry Andric   bool isCompatibleFile(const object::ObjectFile &Obj) const override;
320b57cec5SDimitry Andric 
330b57cec5SDimitry Andric   static std::unique_ptr<RuntimeDyldCOFF>
340b57cec5SDimitry Andric   create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr,
350b57cec5SDimitry Andric          JITSymbolResolver &Resolver);
360b57cec5SDimitry Andric 
370b57cec5SDimitry Andric protected:
RuntimeDyldCOFF(RuntimeDyld::MemoryManager & MemMgr,JITSymbolResolver & Resolver,unsigned PointerSize,uint32_t PointerReloc)380b57cec5SDimitry Andric   RuntimeDyldCOFF(RuntimeDyld::MemoryManager &MemMgr,
39*5ffd83dbSDimitry Andric                   JITSymbolResolver &Resolver, unsigned PointerSize,
40*5ffd83dbSDimitry Andric                   uint32_t PointerReloc)
41*5ffd83dbSDimitry Andric       : RuntimeDyldImpl(MemMgr, Resolver), PointerSize(PointerSize),
42*5ffd83dbSDimitry Andric         PointerReloc(PointerReloc) {
43*5ffd83dbSDimitry Andric     assert((PointerSize == 4 || PointerSize == 8) && "Unexpected pointer size");
44*5ffd83dbSDimitry Andric   }
45*5ffd83dbSDimitry Andric 
460b57cec5SDimitry Andric   uint64_t getSymbolOffset(const SymbolRef &Sym);
47*5ffd83dbSDimitry Andric   uint64_t getDLLImportOffset(unsigned SectionID, StubMap &Stubs,
48*5ffd83dbSDimitry Andric                               StringRef Name, bool SetSectionIDMinus1 = false);
49*5ffd83dbSDimitry Andric 
getImportSymbolPrefix()50*5ffd83dbSDimitry Andric   static constexpr StringRef getImportSymbolPrefix() { return "__imp_"; }
51*5ffd83dbSDimitry Andric 
52*5ffd83dbSDimitry Andric private:
53*5ffd83dbSDimitry Andric   unsigned PointerSize;
54*5ffd83dbSDimitry Andric   uint32_t PointerReloc;
550b57cec5SDimitry Andric };
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric } // end namespace llvm
580b57cec5SDimitry Andric 
590b57cec5SDimitry Andric #undef DEBUG_TYPE
600b57cec5SDimitry Andric 
610b57cec5SDimitry Andric #endif
62