Alexander Shaposhnikov | d911ed1 | 2019-02-02 00:38:07 +0000 | [diff] [blame] | 1 | //===- MachOObjcopy.cpp -----------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 127252b | 2019-02-11 08:25:19 +0000 | [diff] [blame] | 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 |
Alexander Shaposhnikov | d911ed1 | 2019-02-02 00:38:07 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "MachOObjcopy.h" |
| 10 | #include "../CopyConfig.h" |
Alexander Shaposhnikov | d911ed1 | 2019-02-02 00:38:07 +0000 | [diff] [blame] | 11 | #include "MachOReader.h" |
| 12 | #include "MachOWriter.h" |
| 13 | #include "llvm/Support/Error.h" |
| 14 | |
| 15 | namespace llvm { |
| 16 | namespace objcopy { |
| 17 | namespace macho { |
| 18 | |
| 19 | Error 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 |