universal-file-flattening.test
8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
## This test checks that a universal file is flattened correctly.
# RUN: yaml2obj %s -o %t-universal.o
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o
# RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only arm64
## Check that the binary is present:
# RUN: llvm-ar t %t.lib | \
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
# CHECK-NAMES: [[PREFIX]]-universal.o
## Check that symbols are present:
# RUN: llvm-nm --print-armap %t.lib | \
# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
# CHECK-SYMBOLS: Archive map
# CHECK-SYMBOLS-NEXT: _arm64 in [[PREFIX]]-universal.o
# CHECK-SYMBOLS-EMPTY:
## Check that the output archive is in Darwin format:
# RUN: llvm-objdump --macho --archive-headers %t.lib | \
# RUN: FileCheck %s --check-prefix=FORMAT -DPREFIX=%basename_t.tmp -DARCHIVE=%t.lib
# FORMAT: Archive : [[ARCHIVE]]
# FORMAT-NEXT: __.SYMDEF
# FORMAT-NEXT: [[PREFIX]]-universal.o
# FORMAT-NOT: {{.}}
## Passing both a universal file and an object file:
# RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o %t-input1.o -arch_only x86_64
# RUN: llvm-ar t %t.lib | \
# RUN: FileCheck %s --check-prefix=BOTH-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
# RUN: llvm-nm --print-armap %t.lib | \
# RUN: FileCheck %s --check-prefix=BOTH-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
# BOTH-NAMES: [[PREFIX]]-universal.o
# BOTH-NAMES-NEXT: [[PREFIX]]-input1.o
# BOTH-SYMBOLS: Archive map
# BOTH-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-universal.o
# BOTH-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
# BOTH-SYMBOLS-EMPTY:
## Passing both a universal file and an object file but filtering out the object file:
# RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o %t-input1.o -arch_only arm64
# RUN: llvm-ar t %t.lib | \
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
# RUN: llvm-nm --print-armap %t.lib | \
# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
## Universal file containing an archive:
# RUN: rm -f %t.ar
# RUN: llvm-ar cr %t.ar %t-input1.o %t-input2.o
# RUN: llvm-lipo %t.ar -create -output %t-fat-with-archive.o
# RUN: llvm-libtool-darwin -static -o %t.lib %t-fat-with-archive.o -arch_only x86_64
# RUN: llvm-ar t %t.lib | \
# RUN: FileCheck %s --check-prefix=ARCHIVE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
# RUN: llvm-nm --print-armap %t.lib | \
# RUN: FileCheck %s --check-prefix=ARCHIVE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
# ARCHIVE-NAMES: [[PREFIX]]-input1.o
# ARCHIVE-NAMES-NEXT: [[PREFIX]]-input2.o
# ARCHIVE-SYMBOLS: Archive map
# ARCHIVE-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
# ARCHIVE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
# ARCHIVE-SYMBOLS-EMPTY:
## Allow arch_only to be specified more than once (pick the last one):
# RUN: llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only arm64 -arch_only x86_64
# RUN: llvm-ar t %t.lib | \
# RUN: FileCheck %s --check-prefix=DOUBLE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
# RUN: llvm-nm --print-armap %t.lib | \
# RUN: FileCheck %s --check-prefix=DOUBLE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
# DOUBLE-NAMES: [[PREFIX]]-universal.o
# DOUBLE-SYMBOLS: Archive map
# DOUBLE-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-universal.o
# DOUBLE-SYMBOLS-EMPTY:
## Invalid architecture:
# RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only arch101 2>&1 | \
# RUN: FileCheck %s --check-prefix=INVALID-ARCH
# INVALID-ARCH: invalid architecture 'arch101': valid architecture names are
## Empty architecture:
# RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only "" 2>&1 | \
# RUN: FileCheck %s --check-prefix=EMPTY-ARCH
# EMPTY-ARCH: invalid architecture '': valid architecture names are
## Missing architecture:
# RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only ppc 2>&1 | \
# RUN: FileCheck %s --check-prefix=MISSING-ARCH
# MISSING-ARCH: error: no library created (no object files in input files matching -arch_only ppc)
## arch_only missing argument:
# RUN: not llvm-libtool-darwin -static -o %t.lib %t-universal.o -arch_only 2>&1 | \
# RUN: FileCheck %s --check-prefix=REQUIRE-ARCH
# REQUIRE-ARCH: for the --arch_only option: requires a value!
## x86_64-arm64-universal.yaml
--- !fat-mach-o
FatHeader:
magic: 0xCAFEBABE
nfat_arch: 2
FatArchs:
- cputype: 0x01000007
cpusubtype: 0x00000003
offset: 0x0000000000001000
size: 352
align: 12
- cputype: 0x0100000C
cpusubtype: 0x00000000
offset: 0x0000000000004000
size: 384
align: 14
Slices:
- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x00000001
ncmds: 2
sizeofcmds: 176
flags: 0x00002000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 152
segname: ''
vmaddr: 0
vmsize: 15
fileoff: 312
filesize: 15
maxprot: 7
initprot: 7
nsects: 1
flags: 0
Sections:
- sectname: __text
segname: __TEXT
addr: 0x0000000000000000
size: 15
offset: 0x00000138
align: 4
reloff: 0x00000000
nreloc: 0
flags: 0x80000400
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
content: 554889E531C0C745FC000000005DC3
- cmd: LC_SYMTAB
cmdsize: 24
symoff: 328
nsyms: 1
stroff: 344
strsize: 8
LinkEditData:
NameList:
- n_strx: 1
n_type: 0x0F
n_sect: 1
n_desc: 0
n_value: 0
StringTable:
- ''
- _x86_64
- ''
- !mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x0100000C
cpusubtype: 0x00000000
filetype: 0x00000001
ncmds: 2
sizeofcmds: 176
flags: 0x00002000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 152
segname: ''
vmaddr: 0
vmsize: 24
fileoff: 312
filesize: 24
maxprot: 7
initprot: 7
nsects: 1
flags: 0
Sections:
- sectname: __text
segname: __TEXT
addr: 0x0000000000000000
size: 24
offset: 0x00000138
align: 2
reloff: 0x00000000
nreloc: 0
flags: 0x80000400
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
content: FF4300D1FF0F00B908008052E00308AAFF430091C0035FD6
- cmd: LC_SYMTAB
cmdsize: 24
symoff: 336
nsyms: 2
stroff: 368
strsize: 16
LinkEditData:
NameList:
- n_strx: 7
n_type: 0x0E
n_sect: 1
n_desc: 0
n_value: 0
- n_strx: 1
n_type: 0x0F
n_sect: 1
n_desc: 0
n_value: 0
StringTable:
- ''
- _arm64
- ltmp0
- ''
- ''
- ''
...