1 ## This test checks that a universal object file is flattened correctly.
3 # RUN: yaml2obj %s -o %t-universal.o
4 # RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
5 # RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o
7 # RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only arm64
9 ## Check that the binary is present:
10 # RUN: llvm-ar t %t.lib | \
11 # RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
13 # CHECK-NAMES: [[PREFIX]]-universal.o
15 ## Check that symbols are present:
16 # RUN: llvm-nm --print-armap %t.lib | \
17 # RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
19 # CHECK-SYMBOLS: Archive map
20 # CHECK-SYMBOLS-NEXT: _arm64 in [[PREFIX]]-universal.o
21 # CHECK-SYMBOLS-EMPTY:
23 ## Check that the output archive is in Darwin format:
24 # RUN: llvm-objdump --macho --archive-headers %t.lib | \
25 # RUN: FileCheck %s --check-prefix=FORMAT -DPREFIX=%basename_t.tmp -DARCHIVE=%t.lib
27 # FORMAT: Archive : [[ARCHIVE]]
28 # FORMAT-NEXT: __.SYMDEF
29 # FORMAT-NEXT: [[PREFIX]]-universal.o
32 ## Passing both a universal file and an object file:
33 # RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o %t-input1.o -arch_only x86_64
34 # RUN: llvm-ar t %t.lib | \
35 # RUN: FileCheck %s --check-prefix=BOTH-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
36 # RUN: llvm-nm --print-armap %t.lib | \
37 # RUN: FileCheck %s --check-prefix=BOTH-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
39 # BOTH-NAMES: [[PREFIX]]-universal.o
40 # BOTH-NAMES-NEXT: [[PREFIX]]-input1.o
42 # BOTH-SYMBOLS: Archive map
43 # BOTH-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-universal.o
44 # BOTH-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
47 ## Passing both a universal file and an object file but filtering out the object file:
48 # RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o %t-input1.o -arch_only arm64
49 # RUN: llvm-ar t %t.lib | \
50 # RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
51 # RUN: llvm-nm --print-armap %t.lib | \
52 # RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
54 ## Universal file containing an archive:
56 # RUN: llvm-ar cr %t.ar %t-input1.o %t-input2.o
57 # RUN: llvm-lipo %t.ar -create -output %t-fat-with-archive.o
58 # RUN: llvm-libtool-darwin -static -o %t.lib %t-fat-with-archive.o -arch_only x86_64
59 # RUN: llvm-ar t %t.lib | \
60 # RUN: FileCheck %s --check-prefix=ARCHIVE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
61 # RUN: llvm-nm --print-armap %t.lib | \
62 # RUN: FileCheck %s --check-prefix=ARCHIVE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
64 # ARCHIVE-NAMES: [[PREFIX]]-input1.o
65 # ARCHIVE-NAMES-NEXT: [[PREFIX]]-input2.o
67 # ARCHIVE-SYMBOLS: Archive map
68 # ARCHIVE-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
69 # ARCHIVE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
70 # ARCHIVE-SYMBOLS-EMPTY:
72 ## Allow arch_only to be specified more than once (pick the last one):
73 # RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only arm64 -arch_only x86_64
74 # RUN: llvm-ar t %t.lib | \
75 # RUN: FileCheck %s --check-prefix=DOUBLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
76 # RUN: llvm-nm --print-armap %t.lib | \
77 # RUN: FileCheck %s --check-prefix=DOUBLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
79 # DOUBLE-NAMES: [[PREFIX]]-universal.o
81 # DOUBLE-SYMBOLS: Archive map
82 # DOUBLE-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-universal.o
83 # DOUBLE-SYMBOLS-EMPTY:
85 ## Invalid architecture:
86 # RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only arch101 2>&1 | \
87 # RUN: FileCheck %s --check-prefix=INVALID-ARCH
89 # INVALID-ARCH: invalid architecture 'arch101': valid architecture names are
91 ## Empty architecture:
92 # RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only "" 2>&1 | \
93 # RUN: FileCheck %s --check-prefix=EMPTY-ARCH
95 # EMPTY-ARCH: invalid architecture '': valid architecture names are
97 ## Missing architecture:
98 # RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only ppc 2>&1 | \
99 # RUN: FileCheck %s --check-prefix=MISSING-ARCH
101 # MISSING-ARCH: error: no library created (no object files in input files matching -arch_only ppc)
103 ## arch_only missing argument:
104 # RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only 2>&1 | \
105 # RUN: FileCheck %s --check-prefix=REQUIRE-ARCH
107 # REQUIRE-ARCH: -arch_only: missing argument
109 ## x86_64-arm64-universal.yaml
115 - cputype: 0x01000007
116 cpusubtype: 0x00000003
117 offset: 0x0000000000001000
120 - cputype: 0x0100000C
121 cpusubtype: 0x00000000
122 offset: 0x0000000000004000
130 cpusubtype: 0x00000003
151 addr: 0x0000000000000000
158 reserved1: 0x00000000
159 reserved2: 0x00000000
160 reserved3: 0x00000000
161 content: 554889E531C0C745FC000000005DC3
183 cpusubtype: 0x00000000
204 addr: 0x0000000000000000
211 reserved1: 0x00000000
212 reserved2: 0x00000000
213 reserved3: 0x00000000
214 content: FF4300D1FF0F00B908008052E00308AAFF430091C0035FD6