LCOV - code coverage report
Current view: top level - lib/ExecutionEngine/RuntimeDyld - RuntimeDyldCOFF.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 17 24 70.8 %
Date: 2017-09-14 15:23:50 Functions: 5 7 71.4 %
Legend: Lines: hit not hit

          Line data    Source code
       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"
      15             : #include "Targets/RuntimeDyldCOFFI386.h"
      16             : #include "Targets/RuntimeDyldCOFFThumb.h"
      17             : #include "Targets/RuntimeDyldCOFFX86_64.h"
      18             : #include "llvm/ADT/STLExtras.h"
      19             : #include "llvm/ADT/Triple.h"
      20             : #include "llvm/Object/ObjectFile.h"
      21             : 
      22             : using namespace llvm;
      23             : using namespace llvm::object;
      24             : 
      25             : #define DEBUG_TYPE "dyld"
      26             : 
      27             : namespace {
      28             : 
      29           6 : class LoadedCOFFObjectInfo final
      30             :     : public LoadedObjectInfoHelper<LoadedCOFFObjectInfo,
      31             :                                     RuntimeDyld::LoadedObjectInfo> {
      32             : public:
      33             :   LoadedCOFFObjectInfo(
      34             :       RuntimeDyldImpl &RTDyld,
      35             :       RuntimeDyld::LoadedObjectInfo::ObjSectionToIDMap ObjSecToIDMap)
      36           3 :       : LoadedObjectInfoHelper(RTDyld, std::move(ObjSecToIDMap)) {}
      37             : 
      38             :   OwningBinary<ObjectFile>
      39           0 :   getObjectForDebug(const ObjectFile &Obj) const override {
      40           0 :     return OwningBinary<ObjectFile>();
      41             :   }
      42             : };
      43             : }
      44             : 
      45             : namespace llvm {
      46             : 
      47             : std::unique_ptr<RuntimeDyldCOFF>
      48           3 : llvm::RuntimeDyldCOFF::create(Triple::ArchType Arch,
      49             :                               RuntimeDyld::MemoryManager &MemMgr,
      50             :                               JITSymbolResolver &Resolver) {
      51           3 :   switch (Arch) {
      52           0 :   default: llvm_unreachable("Unsupported target for RuntimeDyldCOFF.");
      53           1 :   case Triple::x86:
      54           3 :     return make_unique<RuntimeDyldCOFFI386>(MemMgr, Resolver);
      55           1 :   case Triple::thumb:
      56           3 :     return make_unique<RuntimeDyldCOFFThumb>(MemMgr, Resolver);
      57           1 :   case Triple::x86_64:
      58           3 :     return make_unique<RuntimeDyldCOFFX86_64>(MemMgr, Resolver);
      59             :   }
      60             : }
      61             : 
      62             : std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
      63           3 : RuntimeDyldCOFF::loadObject(const object::ObjectFile &O) {
      64           9 :   if (auto ObjSectionToIDOrErr = loadObjectImpl(O)) {
      65           9 :     return llvm::make_unique<LoadedCOFFObjectInfo>(*this, *ObjSectionToIDOrErr);
      66             :   } else {
      67           0 :     HasError = true;
      68           0 :     raw_string_ostream ErrStream(ErrorStr);
      69           0 :     logAllUnhandledErrors(ObjSectionToIDOrErr.takeError(), ErrStream, "");
      70           0 :     return nullptr;
      71             :   }
      72             : }
      73             : 
      74          23 : uint64_t RuntimeDyldCOFF::getSymbolOffset(const SymbolRef &Sym) {
      75             :   // The value in a relocatable COFF object is the offset.
      76          23 :   return Sym.getValue();
      77             : }
      78             : 
      79           3 : bool RuntimeDyldCOFF::isCompatibleFile(const object::ObjectFile &Obj) const {
      80           6 :   return Obj.isCOFF();
      81             : }
      82             : 
      83             : } // namespace llvm

Generated by: LCOV version 1.13