| 1 | //===-------------- XCOFF.cpp - JIT linker function for XCOFF -------------===// |
|---|---|
| 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 | // XCOFF jit-link function. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "llvm/ExecutionEngine/JITLink/XCOFF.h" |
| 14 | #include "llvm/ExecutionEngine/JITLink/XCOFF_ppc64.h" |
| 15 | #include "llvm/Object/XCOFFObjectFile.h" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | |
| 19 | #define DEBUG_TYPE "jitlink" |
| 20 | |
| 21 | namespace llvm { |
| 22 | namespace jitlink { |
| 23 | |
| 24 | Expected<std::unique_ptr<LinkGraph>> |
| 25 | createLinkGraphFromXCOFFObject(MemoryBufferRef ObjectBuffer, |
| 26 | std::shared_ptr<orc::SymbolStringPool> SSP) { |
| 27 | // Check magic |
| 28 | file_magic Magic = identify_magic(magic: ObjectBuffer.getBuffer()); |
| 29 | if (Magic != file_magic::xcoff_object_64) |
| 30 | return make_error<JITLinkError>(Args: "Invalid XCOFF 64 Header"); |
| 31 | |
| 32 | // TODO: See if we need to add more checks |
| 33 | // |
| 34 | return createLinkGraphFromXCOFFObject_ppc64(ObjectBuffer, SSP: std::move(SSP)); |
| 35 | } |
| 36 | |
| 37 | void link_XCOFF(std::unique_ptr<LinkGraph> G, |
| 38 | std::unique_ptr<JITLinkContext> Ctx) { |
| 39 | link_XCOFF_ppc64(G: std::move(G), Ctx: std::move(Ctx)); |
| 40 | } |
| 41 | |
| 42 | } // namespace jitlink |
| 43 | } // namespace llvm |
| 44 |