brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 35502f4 Raw
40 lines · cpp
1//===------------------ COFF.cpp - COFF format utilities ------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "llvm/ExecutionEngine/Orc/COFF.h"10#include "llvm/Object/Binary.h"11 12#define DEBUG_TYPE "orc"13 14namespace llvm::orc {15 16Expected<bool> COFFImportFileScanner::operator()(object::Archive &A,17                                                 MemoryBufferRef MemberBuf,18                                                 size_t Index) const {19  // Try to build a binary for the member.20  auto Bin = object::createBinary(MemberBuf);21  if (!Bin) {22    // If we can't then consume the error and return false (i.e. not loadable).23    consumeError(Bin.takeError());24    return false;25  }26 27  // If this is a COFF import file then handle it and return false (not28  // loadable).29  if ((*Bin)->isCOFFImportFile()) {30    ImportedDynamicLibraries.insert((*Bin)->getFileName().str());31    return false;32  }33 34  // Otherwise the member is loadable (at least as far as COFFImportFileScanner35  // is concerned), so return true;36  return true;37}38 39} // namespace llvm::orc40