RuntimeDyldCOFF.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //===-- RuntimeDyldCOFF.h - Run-time dynamic linker for MC-JIT ---*- C++ -*-==//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // COFF support for MC-JIT runtime dynamic linker.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_RUNTIME_DYLD_COFF_H
  13. #define LLVM_RUNTIME_DYLD_COFF_H
  14. #include "RuntimeDyldImpl.h"
  15. #define DEBUG_TYPE "dyld"
  16. using namespace llvm;
  17. namespace llvm {
  18. // Common base class for COFF dynamic linker support.
  19. // Concrete subclasses for each target can be found in ./Targets.
  20. class RuntimeDyldCOFF : public RuntimeDyldImpl {
  21. public:
  22. std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
  23. loadObject(const object::ObjectFile &Obj) override;
  24. bool isCompatibleFile(const object::ObjectFile &Obj) const override;
  25. static std::unique_ptr<RuntimeDyldCOFF>
  26. create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr,
  27. JITSymbolResolver &Resolver);
  28. protected:
  29. RuntimeDyldCOFF(RuntimeDyld::MemoryManager &MemMgr,
  30. JITSymbolResolver &Resolver, unsigned PointerSize,
  31. uint32_t PointerReloc)
  32. : RuntimeDyldImpl(MemMgr, Resolver), PointerSize(PointerSize),
  33. PointerReloc(PointerReloc) {
  34. assert((PointerSize == 4 || PointerSize == 8) && "Unexpected pointer size");
  35. }
  36. uint64_t getSymbolOffset(const SymbolRef &Sym);
  37. uint64_t getDLLImportOffset(unsigned SectionID, StubMap &Stubs,
  38. StringRef Name, bool SetSectionIDMinus1 = false);
  39. static constexpr StringRef getImportSymbolPrefix() { return "__imp_"; }
  40. private:
  41. unsigned PointerSize;
  42. uint32_t PointerReloc;
  43. };
  44. } // end namespace llvm
  45. #undef DEBUG_TYPE
  46. #endif