summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/MachO/MachOObjcopy.cpp
blob: 33aec0497b86037bf3102d401b0237a32ea88aeb (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
//===- MachOObjcopy.cpp -----------------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "MachOObjcopy.h"
#include "../CopyConfig.h"
#include "MachOReader.h"
#include "MachOWriter.h"
#include "llvm/Support/Error.h"

namespace llvm {
namespace objcopy {
namespace macho {

Error executeObjcopyOnBinary(const CopyConfig &Config,
                             object::MachOObjectFile &In, Buffer &Out) {
  MachOReader Reader(In);
  std::unique_ptr<Object> O = Reader.create();
  assert(O && "Unable to deserialize MachO object");
  MachOWriter Writer(*O, In.is64Bit(), In.isLittleEndian(), Out);
  return Writer.write();
}

} // end namespace macho
} // end namespace objcopy
} // end namespace llvm
OpenPOWER on IntegriCloud