1 //===-- RuntimeDyldCOFF.cpp - Run-time dynamic linker for MC-JIT -*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Implementation of COFF support for the MC-JIT runtime dynamic linker.
12 //===----------------------------------------------------------------------===//
14 #include "RuntimeDyldCOFF.h"
15 #include "Targets/RuntimeDyldCOFFX86_64.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/Object/ObjectFile.h"
21 using namespace llvm::object;
23 #define DEBUG_TYPE "dyld"
27 class LoadedCOFFObjectInfo
28 : public RuntimeDyld::LoadedObjectInfoHelper<LoadedCOFFObjectInfo> {
30 LoadedCOFFObjectInfo(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,
32 : LoadedObjectInfoHelper(RTDyld, BeginIdx, EndIdx) {}
34 OwningBinary<ObjectFile>
35 getObjectForDebug(const ObjectFile &Obj) const override {
36 return OwningBinary<ObjectFile>();
43 std::unique_ptr<RuntimeDyldCOFF>
44 llvm::RuntimeDyldCOFF::create(Triple::ArchType Arch,
45 RuntimeDyld::MemoryManager &MemMgr,
46 RuntimeDyld::SymbolResolver &Resolver) {
49 llvm_unreachable("Unsupported target for RuntimeDyldCOFF.");
52 return make_unique<RuntimeDyldCOFFX86_64>(MemMgr, Resolver);
56 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
57 RuntimeDyldCOFF::loadObject(const object::ObjectFile &O) {
58 unsigned SectionStartIdx, SectionEndIdx;
59 std::tie(SectionStartIdx, SectionEndIdx) = loadObjectImpl(O);
60 return llvm::make_unique<LoadedCOFFObjectInfo>(*this, SectionStartIdx,
64 uint64_t RuntimeDyldCOFF::getSymbolOffset(const SymbolRef &Sym) {
65 // The value in a relocatable COFF object is the offset.
66 return Sym.getValue();
69 bool RuntimeDyldCOFF::isCompatibleFile(const object::ObjectFile &Obj) const {