Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-objcopy][MachO] Add support for universal binaries
This diff adds support for universal binaries to llvm-objcopy. This is a recommit of 32c8435 with the asan issue fixed. Test plan: make check-all Differential revision: https://reviews.llvm.org/D88400
- Loading branch information
Alexander Shaposhnikov
committed
Oct 6, 2020
1 parent
c08d48f
commit 315970d
Showing
8 changed files
with
190 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This test verifies that llvm-objcopy copies a univeral Mach-O object file properly. | ||
|
||
# RUN: yaml2obj %p/Inputs/i386.yaml -o %t.i386 | ||
# RUN: yaml2obj %p/Inputs/x86_64.yaml -o %t.x86_64 | ||
|
||
## Case 1: copy a universal object containing regular Mach-O objects. | ||
# RUN: llvm-lipo %t.i386 %t.x86_64 -create -output %t.universal | ||
# RUN: llvm-objcopy %t.universal %t.universal.copy | ||
# RUN: llvm-lipo %t.universal.copy -archs | FileCheck --check-prefix=VERIFY_ARCHS %s | ||
# RUN: llvm-lipo %t.universal.copy -thin i386 -output %t.i386.copy | ||
# RUN: llvm-lipo %t.universal.copy -thin x86_64 -output %t.x86_64.copy | ||
# RUN: cmp %t.i386 %t.i386.copy | ||
# RUN: cmp %t.x86_64 %t.x86_64.copy | ||
|
||
## Case 2: copy a universal object file containing an archive. | ||
# RUN: rm -f %t.archive.i386 | ||
# RUN: llvm-ar cr %t.archive.i386 %t.i386 | ||
# RUN: llvm-lipo %t.archive.i386 %t.x86_64 -create -output %t.universal.containing.archive | ||
# RUN: llvm-objcopy %t.universal.containing.archive %t.universal.containing.archive.copy | ||
# RUN: llvm-lipo %t.universal.containing.archive.copy -archs | FileCheck --check-prefix=VERIFY_ARCHS %s | ||
# RUN: llvm-lipo %t.universal.containing.archive.copy -thin i386 -output %t.archive.i386.copy | ||
# RUN: llvm-lipo %t.universal.containing.archive.copy -thin x86_64 -output %t.archive.x86_64.copy | ||
# RUN: cmp %t.archive.i386 %t.archive.i386.copy | ||
# RUN: cmp %t.x86_64 %t.archive.x86_64.copy | ||
|
||
## Case 3: copy an archive containing a universal object. | ||
# RUN: llvm-ar cr %t.archive.containing.universal %t.universal | ||
# RUN: llvm-objcopy %t.archive.containing.universal %t.archive.containing.universal.copy | ||
|
||
## Case 4: try to copy a universal object file contaning a bitcode slice. | ||
# RUN: echo 'target triple = "arm64-apple-ios8.0.0"' | llvm-as -o %t.bitcode | ||
# RUN: llvm-lipo %t.bitcode %t.x86_64 -create -output %t.universal.containing.bitcode | ||
# RUN: not llvm-objcopy %t.universal.containing.bitcode %t.universal.containing.bitcode.copy 2>&1 \ | ||
# RUN: | FileCheck --check-prefix=UNSUPPORTED_UNIVERSAL_OBJECT %s | ||
|
||
## Case 5: try to copy an archive containing an unsupported universal object. | ||
# RUN: llvm-ar cr %t.archive.universal.bitcode %t.universal.containing.bitcode | ||
# RUN: not llvm-objcopy %t.archive.universal.bitcode %t.archive.universal.bitcode.copy 2>&1 \ | ||
# RUN: | FileCheck --check-prefix=UNSUPPORTED_UNIVERSAL_OBJECT %s | ||
|
||
# VERIFY_ARCHS: i386 x86_64 | ||
# UNSUPPORTED_UNIVERSAL_OBJECT: slice for 'arm64' of the universal Mach-O binary {{.*}} is not a Mach-O object or an archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//===- llvm-objcopy.h -------------------------------------------*- 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_TOOLS_OBJCOPY_OBJCOPY_H | ||
#define LLVM_TOOLS_OBJCOPY_OBJCOPY_H | ||
|
||
#include "llvm/Support/Error.h" | ||
|
||
namespace llvm { | ||
|
||
struct NewArchiveMember; | ||
|
||
namespace object { | ||
|
||
class Archive; | ||
|
||
} // end namespace object | ||
|
||
namespace objcopy { | ||
struct CopyConfig; | ||
Expected<std::vector<NewArchiveMember>> | ||
createNewArchiveMembers(CopyConfig &Config, const object::Archive &Ar); | ||
|
||
} // end namespace objcopy | ||
} // end namespace llvm | ||
|
||
#endif // LLVM_TOOLS_OBJCOPY_OBJCOPY_H |