blob: 33aec0497b86037bf3102d401b0237a32ea88aeb [file] [log] [blame]
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +00001//===- MachOObjcopy.cpp -----------------------------------------*- C++ -*-===//
2//
Chandler Carruth127252b2019-02-11 08:25:19 +00003// 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
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "MachOObjcopy.h"
10#include "../CopyConfig.h"
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +000011#include "MachOReader.h"
12#include "MachOWriter.h"
13#include "llvm/Support/Error.h"
14
15namespace llvm {
16namespace objcopy {
17namespace macho {
18
19Error executeObjcopyOnBinary(const CopyConfig &Config,
20 object::MachOObjectFile &In, Buffer &Out) {
21 MachOReader Reader(In);
22 std::unique_ptr<Object> O = Reader.create();
23 assert(O && "Unable to deserialize MachO object");
24 MachOWriter Writer(*O, In.is64Bit(), In.isLittleEndian(), Out);
25 return Writer.write();
26}
27
28} // end namespace macho
29} // end namespace objcopy
30} // end namespace llvm