aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/JITLink/XCOFF.cpp
blob: cb026538632a9d9bc145ae1f33a620d0c17769be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//===-------------- XCOFF.cpp - JIT linker function for XCOFF -------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// XCOFF jit-link function.
//
//===----------------------------------------------------------------------===//

#include "llvm/ExecutionEngine/JITLink/XCOFF.h"
#include "llvm/ExecutionEngine/JITLink/XCOFF_ppc64.h"
#include "llvm/Object/XCOFFObjectFile.h"

using namespace llvm;

#define DEBUG_TYPE "jitlink"

namespace llvm {
namespace jitlink {

Expected<std::unique_ptr<LinkGraph>>
createLinkGraphFromXCOFFObject(MemoryBufferRef ObjectBuffer,
                               std::shared_ptr<orc::SymbolStringPool> SSP) {
  // Check magic
  file_magic Magic = identify_magic(ObjectBuffer.getBuffer());
  if (Magic != file_magic::xcoff_object_64)
    return make_error<JITLinkError>("Invalid XCOFF 64 Header");

  // TODO: See if we need to add more checks
  //
  return createLinkGraphFromXCOFFObject_ppc64(ObjectBuffer, std::move(SSP));
}

void link_XCOFF(std::unique_ptr<LinkGraph> G,
                std::unique_ptr<JITLinkContext> Ctx) {
  link_XCOFF_ppc64(std::move(G), std::move(Ctx));
}

} // namespace jitlink
} // namespace llvm