• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## This test checks that a correct universal binary is produced when
2## llvm-libtool-darwin is given object files for multiple architectures.
3
4## Check that the subtypes of cputype CPU_TYPE_ARM are stored in a fat file:
5# RUN: yaml2obj %s -o %t.armv6 -DTYPE=0xC -DSUBTYPE=0x6 -DSTRING=_armv6
6# RUN: yaml2obj %s -o %t.armv7 -DTYPE=0xC -DSUBTYPE=0x9 -DSTRING=_armv7
7
8# RUN: llvm-libtool-darwin -static -o %t.lib %t.armv6 %t.armv7
9
10## Check that architectures are present in the universal output:
11# RUN: llvm-lipo -info %t.lib | \
12# RUN:   FileCheck %s --check-prefix=ARCHS -DFILE=%t.lib
13
14# ARCHS: Architectures in the fat file: [[FILE]] are: armv6 armv7
15
16## Check that the files with the same architecture are combined in an archive:
17# RUN: llvm-libtool-darwin -static -o %t.lib %t.armv6 %t.armv6 %t.armv7
18# RUN: llvm-lipo -info %t.lib | \
19# RUN:   FileCheck %s --check-prefix=ARCHS -DFILE=%t.lib
20# RUN: llvm-objdump --macho --arch all --all-headers %t.lib | \
21# RUN:   FileCheck %s --check-prefix=UNIVERSAL-MEMBERS -DFILE=%t.lib -DPREFIX=%basename_t.tmp --implicit-check-not=Archive
22
23# UNIVERSAL-MEMBERS:      Archive : [[FILE]] (architecture armv6)
24# UNIVERSAL-MEMBERS-NEXT: __.SYMDEF
25# UNIVERSAL-MEMBERS-NEXT: [[PREFIX]].armv6
26# UNIVERSAL-MEMBERS-NEXT: [[PREFIX]].armv6
27# UNIVERSAL-MEMBERS:      Archive : [[FILE]] (architecture armv7)
28# UNIVERSAL-MEMBERS-NEXT: __.SYMDEF
29# UNIVERSAL-MEMBERS-NEXT: [[PREFIX]].armv7
30
31## Check that the files extracted from a universal output are archives:
32# RUN: llvm-libtool-darwin -static -o %t.lib %t.armv6 %t.armv7
33# RUN: llvm-lipo %t.lib -thin armv7 -output %t-extracted-v7.a
34# RUN: llvm-ar t %t-extracted-v7.a | \
35# RUN:   FileCheck %s --check-prefix=EXTRACT --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
36# RUN: llvm-nm --print-armap %t-extracted-v7.a | \
37# RUN:   FileCheck %s --check-prefix=EXTRACT-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
38
39# EXTRACT: [[PREFIX]].armv7
40
41# EXTRACT-SYMBOLS:      Archive map
42# EXTRACT-SYMBOLS-NEXT: _armv7 in [[PREFIX]].armv7
43# EXTRACT-SYMBOLS-EMPTY:
44
45## Check that the subtypes of cputype CPU_TYPE_X86_64 are stored in a fat file:
46# RUN: yaml2obj %s -o %t.x86_64 -DTYPE=0x01000007 -DSUBTYPE=0x3 -DSTRING=_x86_64
47# RUN: yaml2obj %s -o %t.x86_64_h -DTYPE=0x01000007 -DSUBTYPE=0x8 -DSTRING=_x86_64_h
48# RUN: llvm-libtool-darwin -static -o %t.lib %t.x86_64 %t.x86_64_h
49# RUN: llvm-lipo -info %t.lib | \
50# RUN:   FileCheck %s --check-prefix=ARCHS-X86 -DFILE=%t.lib
51
52# ARCHS-X86: Architectures in the fat file: [[FILE]] are: x86_64 x86_64h
53
54## Check that the subtypes of cputype CPU_TYPE_ARM64 are stored in a fat file:
55## Testing it using llvm-objdump as, currently, there is no support for arm64e
56## under llvm/lib/Object/MachOObjectFile.cpp.
57# RUN: yaml2obj %s -o %t.arm64 -DTYPE=0x0100000C -DSUBTYPE=0x0 -DSTRING=_arm64all
58# RUN: yaml2obj %s -o %t.arm64e -DTYPE=0x0100000C -DSUBTYPE=0x2 -DSTRING=_arm64e
59# RUN: llvm-libtool-darwin -static -o %t.lib %t.arm64 %t.arm64e
60# RUN: llvm-objdump --macho --arch all --all-headers %t.lib | \
61# RUN:   FileCheck %s --check-prefix=UNIVERSAL-MEMBERS-ARM64 -DFILE=%t.lib -DPREFIX=%basename_t.tmp --implicit-check-not=Archive
62
63# UNIVERSAL-MEMBERS-ARM64:      Archive : [[FILE]] (architecture arm64)
64# UNIVERSAL-MEMBERS-ARM64-NEXT: __.SYMDEF
65# UNIVERSAL-MEMBERS-ARM64-NEXT: [[PREFIX]].arm64
66# UNIVERSAL-MEMBERS-ARM64:      Archive : [[FILE]]
67# UNIVERSAL-MEMBERS-ARM64-NEXT: __.SYMDEF
68# UNIVERSAL-MEMBERS-ARM64-NEXT: [[PREFIX]].arm64e
69
70## Check that different cputypes are stored together in a fat file:
71# RUN: yaml2obj %s -o %t.ppc -DTYPE=0x12 -DSUBTYPE=0x0 -DSTRING=_ppcall
72# RUN: llvm-libtool-darwin -static -o %t.lib %t.armv6 %t.ppc
73# RUN: llvm-lipo -info %t.lib | \
74# RUN:   FileCheck %s --check-prefix=ARCHS-CPU -DFILE=%t.lib
75
76# ARCHS-CPU: Architectures in the fat file: [[FILE]] are: ppc armv6
77
78--- !mach-o
79FileHeader:
80  magic:           0xFEEDFACE
81  cputype:         [[TYPE]]
82  cpusubtype:      [[SUBTYPE]]
83  filetype:        0x00000001
84  ncmds:           2
85  sizeofcmds:      148
86  flags:           0x00002000
87LoadCommands:
88  - cmd:             LC_SEGMENT
89    cmdsize:         124
90    segname:         ''
91    vmaddr:          0
92    vmsize:          10
93    fileoff:         280
94    filesize:        10
95    maxprot:         7
96    initprot:        7
97    nsects:          1
98    flags:           0
99  - cmd:             LC_SYMTAB
100    cmdsize:         24
101    symoff:          292
102    nsyms:           1
103    stroff:          304
104    strsize:         8
105LinkEditData:
106  NameList:
107    - n_strx:          1
108      n_type:          0x0F
109      n_sect:          1
110      n_desc:          8
111      n_value:         0
112  StringTable:
113    - ''
114    - [[STRING]]
115    - ''
116...
117