File: cpu-subtype-matching.test

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (277 lines) | stat: -rw-r--r-- 7,615 bytes parent folder | download | duplicates (19)
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
## This test checks that the CPU subtype matching logic is handled correctly.

# RUN: yaml2obj %s --docnum=1 -o %t-armv6.obj
# RUN: yaml2obj %s --docnum=2 -o %t-armv7.obj
# RUN: llvm-as %p/Inputs/arm64-ios.ll -o %t-arm64.bc
# RUN: llvm-as %p/Inputs/armv7-ios.ll -o %t-armv7.bc

# RUN: llvm-libtool-darwin -static -o %t.lib %t-armv6.obj %t-armv7.obj %t-arm64.bc %t-armv7.bc -arch_only armv7

## Check that only armv7 binary is present:
# RUN: llvm-ar t %t.lib | \
# RUN:   FileCheck %s --check-prefix=ARM-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp

# ARM-NAMES: [[PREFIX]]-armv7.obj
# ARM-NAMES-NEXT: [[PREFIX]]-armv7.bc

## Check that only armv7 symbol is present:
# RUN: llvm-nm --print-armap %t.lib | \
# RUN:   FileCheck %s --check-prefix=ARM-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines

# ARM-SYMBOLS:      Archive map
# ARM-SYMBOLS-NEXT: _armv7 in [[PREFIX]]-armv7.obj
# ARM-SYMBOLS-NEXT: _armv7 in [[PREFIX]]-armv7.bc
# ARM-SYMBOLS-EMPTY:

## armv6.yaml
## CPUTYPE:    CPU_TYPE_ARM
## CPUSUBTYPE: CPU_SUBTYPE_ARM_V6
--- !mach-o
FileHeader:
  magic:           0xFEEDFACE
  cputype:         0x0000000C
  cpusubtype:      0x00000006
  filetype:        0x00000001
  ncmds:           2
  sizeofcmds:      148
  flags:           0x00002000
LoadCommands:
  - cmd:             LC_SEGMENT
    cmdsize:         124
    segname:         ''
    vmaddr:          0
    vmsize:          24
    fileoff:         296
    filesize:        24
    maxprot:         7
    initprot:        7
    nsects:          1
    flags:           0
    Sections:
      - sectname:        __text
        segname:         __TEXT
        addr:            0x0000000000000000
        size:            24
        offset:          0x00000128
        align:           2
        reloff:          0x00000000
        nreloc:          0
        flags:           0x80000400
        reserved1:       0x00000000
        reserved2:       0x00000000
        reserved3:       0x00000000
        content:         04D04DE208009FE500008DE504D08DE21EFF2FE100000000
  - cmd:             LC_SYMTAB
    cmdsize:         24
    symoff:          328
    nsyms:           1
    stroff:          340
    strsize:         8
LinkEditData:
  NameList:
    - n_strx:          1
      n_type:          0x0F
      n_sect:          1
      n_desc:          0
      n_value:         0
  StringTable:
    - ''
    - _armv6
    - ''
...

## armv7.yaml
## CPUTYPE:    CPU_TYPE_ARM
## CPUSUBTYPE: CPU_SUBTYPE_ARM_V7
--- !mach-o
FileHeader:
  magic:           0xFEEDFACE
  cputype:         0x0000000C
  cpusubtype:      0x00000009
  filetype:        0x00000001
  ncmds:           2
  sizeofcmds:      148
  flags:           0x00002000
LoadCommands:
  - cmd:             LC_SEGMENT
    cmdsize:         124
    segname:         ''
    vmaddr:          0
    vmsize:          10
    fileoff:         280
    filesize:        10
    maxprot:         7
    initprot:        7
    nsects:          1
    flags:           0
    Sections:
      - sectname:        __text
        segname:         __TEXT
        addr:            0x0000000000000000
        size:            10
        offset:          0x00000118
        align:           1
        reloff:          0x00000000
        nreloc:          0
        flags:           0x80000400
        reserved1:       0x00000000
        reserved2:       0x00000000
        reserved3:       0x00000000
        content:         81B00020009001B07047
  - cmd:             LC_SYMTAB
    cmdsize:         24
    symoff:          292
    nsyms:           1
    stroff:          304
    strsize:         8
LinkEditData:
  NameList:
    - n_strx:          1
      n_type:          0x0F
      n_sect:          1
      n_desc:          8
      n_value:         0
  StringTable:
    - ''
    - _armv7
    - ''
...

# RUN: yaml2obj %s --docnum=3 -o %t-x86_64.obj
# RUN: yaml2obj %s --docnum=4 -o %t-x86_64_h.obj
# RUN: llvm-as %p/Inputs/x86_64-osx.ll -o %t-x86_64.bc
# RUN: llvm-as %p/Inputs/x86_64h-osx.ll -o %t-x86_64_h.bc

# RUN: llvm-libtool-darwin -static -o %t.lib %t-x86_64.obj %t-x86_64_h.obj %t-x86_64.bc %t-x86_64_h.bc -arch_only x86_64

## Check that only x86_64 binary is present:
# RUN: llvm-ar t %t.lib | \
# RUN:   FileCheck %s --check-prefix=X86-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp

# X86-NAMES: [[PREFIX]]-x86_64.obj
# X86-NAMES-NEXT: [[PREFIX]]-x86_64.bc

## Check that only x86_64 symbol is present:
# RUN: llvm-nm --print-armap %t.lib | \
# RUN:   FileCheck %s --check-prefix=X86-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines

# X86-SYMBOLS:      Archive map
# X86-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-x86_64.obj
# X86-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-x86_64.bc
# X86-SYMBOLS-EMPTY:

## x86_64.yaml
## CPUTYPE:    CPU_TYPE_X86_64
## CPUSUBTYPE: CPU_SUBTYPE_X86_64_ALL
--- !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
    - ''
...

## x86_64h.yaml
## CPUTYPE:    CPU_TYPE_X86_64
## CPUSUBTYPE: CPU_SUBTYPE_X86_64_H
--- !mach-o
FileHeader:
  magic:           0xFEEDFACF
  cputype:         0x01000007
  cpusubtype:      0x00000008
  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_h
    - ''
...