LLVM  3.7.0
RuntimeDyldCOFF.cpp
Go to the documentation of this file.
1 //===-- RuntimeDyldCOFF.cpp - Run-time dynamic linker for MC-JIT -*- C++ -*-==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Implementation of COFF support for the MC-JIT runtime dynamic linker.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "RuntimeDyldCOFF.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/Object/ObjectFile.h"
19 
20 using namespace llvm;
21 using namespace llvm::object;
22 
23 #define DEBUG_TYPE "dyld"
24 
25 namespace {
26 
27 class LoadedCOFFObjectInfo
28  : public RuntimeDyld::LoadedObjectInfoHelper<LoadedCOFFObjectInfo> {
29 public:
30  LoadedCOFFObjectInfo(RuntimeDyldImpl &RTDyld, unsigned BeginIdx,
31  unsigned EndIdx)
32  : LoadedObjectInfoHelper(RTDyld, BeginIdx, EndIdx) {}
33 
35  getObjectForDebug(const ObjectFile &Obj) const override {
36  return OwningBinary<ObjectFile>();
37  }
38 };
39 }
40 
41 namespace llvm {
42 
43 std::unique_ptr<RuntimeDyldCOFF>
46  RuntimeDyld::SymbolResolver &Resolver) {
47  switch (Arch) {
48  default:
49  llvm_unreachable("Unsupported target for RuntimeDyldCOFF.");
50  break;
51  case Triple::x86_64:
52  return make_unique<RuntimeDyldCOFFX86_64>(MemMgr, Resolver);
53  }
54 }
55 
56 std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
58  unsigned SectionStartIdx, SectionEndIdx;
59  std::tie(SectionStartIdx, SectionEndIdx) = loadObjectImpl(O);
60  return llvm::make_unique<LoadedCOFFObjectInfo>(*this, SectionStartIdx,
61  SectionEndIdx);
62 }
63 
65  // The value in a relocatable COFF object is the offset.
66  return Sym.getValue();
67 }
68 
70  return Obj.isCOFF();
71 }
72 
73 } // namespace llvm
bool isCompatibleFile(const object::ObjectFile &Obj) const override
This class is the base class for all object file types.
Definition: ObjectFile.h:176
uint64_t getSymbolOffset(const SymbolRef &Sym)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
static std::unique_ptr< RuntimeDyldCOFF > create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, RuntimeDyld::SymbolResolver &Resolver)
bool isCOFF() const
Definition: Binary.h:112
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: ObjectFile.h:114
uint64_t getValue() const
Return the value of the symbol depending on the object this can be an offset or a virtual address...
Definition: ObjectFile.h:314
std::unique_ptr< RuntimeDyld::LoadedObjectInfo > loadObject(const object::ObjectFile &Obj) override