Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / special-symbol-ld-hidden.s
blobf4689f580d41addf822a7de427f3757542d97403
1 # REQUIRES: x86
3 # RUN: rm -rf %t; split-file --no-leading-lines %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/ref-all.s -o %t/ref-all.o
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/ref-reexported.s -o %t/ref-reexported.o
7 ## Check that the hidden symbols(foo11) can't be referenced from HideFoo.tbd when current version is 11.
8 # RUN: not %lld -o /dev/null %t/libHideFoo.tbd %t/ref-all.o -dylib -platform_version macos 11.0.0 11.0.0 2>&1 | FileCheck %s --check-prefix=ERROR
10 ## Check that the hidden symbol(foo11) can be referenced when the current version is NOT 11.
11 # RUN: %lld -o %t/ref-foo-12.dylib %t/libHideFoo.tbd %t/ref-all.o -dylib -platform_version macos 12.0.0 12.0.0
12 # RUN: llvm-objdump --macho --bind %t/ref-foo-12.dylib | FileCheck %s --check-prefix=HAS-FOO
14 ## Check that when we link multiple tbd files, foo11 comes from the tbd where it is visible.
15 # RUN: %lld -o %t/ref-all.dylib %t/libHideFoo.tbd %t/libHasFoo.tbd %t/ref-all.o -dylib -platform_version macos 11.0.0 11.0.0
16 # RUN: llvm-objdump --macho --bind %t/ref-all.dylib | FileCheck %s --check-prefix=FOO
18 ## Check that '$hide$' has no effect on reexported symbols.
19 # RUN: %lld -o %t/reexport.dylib %t/libReexportSystem2.tbd %t/ref-reexported.o -dylib -platform_version macos 11.0.0 11.0.0
20 # RUN: llvm-objdump --macho --bind %t/reexport.dylib | FileCheck %s --check-prefix=REEXP
22 # ERROR: error: undefined symbol: _OBJC_CLASS_$_foo11
24 # HAS-FOO: __DATA __data {{.*}} pointer 0 /HideFoo _OBJC_CLASS_$_foo11
26 # FOO: segment section address type addend dylib symbol
27 # FOO-DAG: __DATA __data {{.*}} pointer 0 /HideFoo _OBJC_CLASS_$_bar
28 # FOO-DAG: __DATA __data {{.*}} pointer 0 /HideFoo _OBJC_CLASS_$_foo10
29 # FOO-DAG: __DATA __data {{.*}} pointer 0 /HasFoo _OBJC_CLASS_$_foo11
30 # FOO-DAG: __DATA __data {{.*}} pointer 0 /HideFoo _xxx
32 # REEXP: __DATA __data {{.*}} pointer 0 libSystem ___nan
34 #--- ref-all.s
35 .data
36 .quad _xxx
37 .quad _OBJC_CLASS_$_foo11
38 .quad _OBJC_CLASS_$_foo10
39 .quad _OBJC_CLASS_$_bar
41 #--- ref-reexported.s
42 .data
43 .quad ___nan
45 #--- libHideFoo.tbd
46 --- !tapi-tbd
47 tbd-version: 4
48 targets: [ x86_64-macos ]
49 uuids:
50 - target: x86_64-macos
51 value: 2E994C7F-3F03-3A07-879C-55690D22BEDA
52 install-name: '/HideFoo'
53 current-version: 9
54 compatibility-version: 4.5.6
55 exports:
56 - targets: [ x86_64-macos ]
57 symbols: [ '$ld$hide$os11.0$_OBJC_CLASS_$_foo11', '$ld$hide$os10.0$_OBJC_CLASS_$_foo10', _xxx ]
58 objc-classes: [foo10, foo11, bar]
59 ...
61 #--- libHasFoo.tbd
62 --- !tapi-tbd
63 tbd-version: 4
64 targets: [ x86_64-macos ]
65 uuids:
66 - target: x86_64-macos
67 value: 2E994C7F-3F03-3A07-879C-55690D22BEDB
68 install-name: '/HasFoo'
69 current-version: 9
70 compatibility-version: 4.5.6
71 exports:
72 - targets: [ x86_64-macos ]
73 symbols: [ _xxx ]
74 objc-classes: [foo10, foo11, bar]
75 ...
77 #--- libReexportSystem2.tbd
78 --- !tapi-tbd
79 tbd-version: 4
80 targets: [ x86_64-macos ]
81 uuids:
82 - target: x86_64-macos
83 value: 00000000-0000-0000-0000-000000000002
84 install-name: '/libReexportSystem2'
85 current-version: 9
86 exports:
87 - targets: [ x86_64-macos ]
88 symbols: [ '$ld$hide$___nan' ]
89 reexported-libraries:
90 - targets: [ x86_64-macos ]
91 libraries: [ '/usr/lib/libSystem.dylib' ]
92 ...