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/RuntimeDyldCOFFI386.h"
16 #include "Targets/RuntimeDyldCOFFX86_64.h"
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Object/ObjectFile.h"
22 using namespace llvm::object;
24 #define DEBUG_TYPE "dyld"
28 class LoadedCOFFObjectInfo final
29 : public RuntimeDyld::LoadedObjectInfoHelper<LoadedCOFFObjectInfo> {
31 LoadedCOFFObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
32 : LoadedObjectInfoHelper(RTDyld, std::move(ObjSecToIDMap)) {}
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<RuntimeDyldCOFFI386>(MemMgr, Resolver);
54 return make_unique<RuntimeDyldCOFFX86_64>(MemMgr, Resolver);
58 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
59 RuntimeDyldCOFF::loadObject(const object::ObjectFile &O) {
60 return llvm::make_unique<LoadedCOFFObjectInfo>(*this, loadObjectImpl(O));
63 uint64_t RuntimeDyldCOFF::getSymbolOffset(const SymbolRef &Sym) {
64 // The value in a relocatable COFF object is the offset.
65 return Sym.getValue();
68 bool RuntimeDyldCOFF::isCompatibleFile(const object::ObjectFile &Obj) const {