Alexander Shaposhnikov | d911ed1 | 2019-02-02 00:38:07 +0000 | [diff] [blame] | 1 | //===- MachOObjcopy.cpp -----------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "MachOObjcopy.h" |
| 11 | #include "../CopyConfig.h" |
| 12 | #include "../llvm-objcopy.h" |
| 13 | #include "MachOReader.h" |
| 14 | #include "MachOWriter.h" |
| 15 | #include "llvm/Support/Error.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | namespace objcopy { |
| 19 | namespace macho { |
| 20 | |
| 21 | Error executeObjcopyOnBinary(const CopyConfig &Config, |
| 22 | object::MachOObjectFile &In, Buffer &Out) { |
| 23 | MachOReader Reader(In); |
| 24 | std::unique_ptr<Object> O = Reader.create(); |
| 25 | assert(O && "Unable to deserialize MachO object"); |
| 26 | MachOWriter Writer(*O, In.is64Bit(), In.isLittleEndian(), Out); |
| 27 | return Writer.write(); |
| 28 | } |
| 29 | |
| 30 | } // end namespace macho |
| 31 | } // end namespace objcopy |
| 32 | } // end namespace llvm |