| 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-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/ExecutionEngine/Orc/COFF.h" |
| 10 | #include "llvm/Object/Binary.h" |
| 11 | |
| 12 | #define DEBUG_TYPE "orc" |
| 13 | |
| 14 | namespace llvm::orc { |
| 15 | |
| 16 | Expected<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(Source: MemberBuf); |
| 21 | if (!Bin) { |
| 22 | // If we can't then consume the error and return false (i.e. not loadable). |
| 23 | consumeError(Err: Bin.takeError()); |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | // If this is a COFF import file then handle it and return false (not |
| 28 | // loadable). |
| 29 | if ((*Bin)->isCOFFImportFile()) { |
| 30 | ImportedDynamicLibraries.insert(x: (*Bin)->getFileName().str()); |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | // Otherwise the member is loadable (at least as far as COFFImportFileScanner |
| 35 | // is concerned), so return true; |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | } // namespace llvm::orc |
| 40 | |