Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / local-symbol-output.s
blobc27e665635c147edd1241def174d195a690169c9
1 # REQUIRES: x86
3 # RUN: rm -rf %t; split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/main.s -o %t/main.o
6 ## Check that -non_global_symbols_no_strip_list and -non_global_symbols_strip_list
7 ## can't be used at the same time.
8 # RUN: not %lld %t/main.o -o /dev/null \
9 # RUN: -non_global_symbols_no_strip_list %t/foo.txt \
10 # RUN: -non_global_symbols_strip_list %t/foo.txt 2>&1 | \
11 # RUN: FileCheck --check-prefix=CONFLICT %s
13 # CONFLICT: error: cannot use both -non_global_symbols_no_strip_list and -non_global_symbols_strip_list
15 ## Check that -x causes none of the local symbols to be emitted.
16 # RUN: %lld %t/main.o -x -o %t/NO-LOCAL.out
17 # RUN: llvm-nm %t/NO-LOCAL.out | FileCheck --check-prefix NO-LOCAL %s
19 # NO-LOCAL-NOT: t _foo
20 # NO-LOCAL-NOT: t _bar
21 # NO-LOCAL-NOT: t _baz
22 # NO-LOCAL: T _main
24 ## Check that when using -x with -non_global_symbols_no_strip_list, whichever appears
25 ## last in the command line arg list will take precedence.
26 # RUN: %lld %t/main.o -x -non_global_symbols_no_strip_list %t/foo.txt -o %t/x_then_no_strip.out
27 # RUN: llvm-nm %t/x_then_no_strip.out | FileCheck --check-prefix X-NO-STRIP %s
29 # RUN: %lld %t/main.o -non_global_symbols_no_strip_list %t/foo.txt -x -o %t/no_strip_then_x.out
30 # RUN: llvm-nm %t/no_strip_then_x.out | FileCheck --check-prefix NO-LOCAL %s
32 # X-NO-STRIP-NOT: t _bar
33 # X-NO-STRIP-DAG: t _foo
34 # X-NO-STRIP-DAG: T _main
36 ## Check that -non_global_symbols_no_strip_list can be specified more than once
37 ## (The final no-strip list is the union of all these)
38 # RUN: %lld %t/main.o -o %t/no_strip_multi.out \
39 # RUN: -non_global_symbols_no_strip_list %t/foo.txt \
40 # RUN: -non_global_symbols_no_strip_list %t/bar.txt
41 # RUN: llvm-nm %t/no_strip_multi.out | FileCheck --check-prefix NO-STRIP-MULTI %s
43 # NO-STRIP-MULTI-NOT: t _baz
44 # NO-STRIP-MULTI-DAG: t _foo
45 # NO-STRIP-MULTI-DAG: t _bar
46 # NO-STRIP-MULTI-DAG: T _main
48 ## Check that when using -x with -non_global_symbols_strip_list, whichever appears
49 ## last in the command line arg list will take precedence.
50 # RUN: %lld %t/main.o -x -non_global_symbols_strip_list %t/foo.txt -o %t/x_then_strip.out
51 # RUN: llvm-nm %t/x_then_strip.out | FileCheck --check-prefix X-STRIP %s
53 # RUN: %lld %t/main.o -non_global_symbols_strip_list %t/foo.txt -x -o %t/strip_then_x.out
54 # RUN: llvm-nm %t/no_strip_then_x.out | FileCheck --check-prefix NO-LOCAL %s
56 # X-STRIP-NOT: t _foo
57 # X-STRIP-DAG: t _bar
58 # X-STRIP-DAG: t _baz
59 # X-STRIP-DAG: T _main
61 ## Check that -non_global_symbols_strip_list can be specified more than once
62 ## (The final strip list is the union of all these)
63 # RUN: %lld %t/main.o -o %t/strip_multi.out \
64 # RUN: -non_global_symbols_strip_list %t/foo.txt \
65 # RUN: -non_global_symbols_strip_list %t/bar.txt
66 # RUN: llvm-nm %t/strip_multi.out | FileCheck --check-prefix STRIP-MULTI %s
68 # STRIP-MULTI-NOT: t _foo
69 # STRIP-MULTI-NOT: t _bar
70 # STRIP-MULTI-DAG: t _baz
71 # STRIP-MULTI-DAG: T _main
73 ## Test interactions with exported_symbol.
74 # RUN: %lld %t/main.o -o %t/strip_all_export_one.out \
75 # RUN: -x -exported_symbol _foo \
76 # RUN: -undefined dynamic_lookup
77 # RUN: llvm-nm %t/strip_all_export_one.out | FileCheck --check-prefix STRIP-EXP %s
79 # STRIP-EXP: U _foo
80 # STRIP-EXP: U dyld_stub_binder
81 # STRIP-EXP-EMPTY:
83 ## Test interactions of -x and -non_global_symbols_strip_list with unexported_symbol.
84 # RUN: %lld %t/main.o -o %t/strip_x_unexport_one.out \
85 # RUN: -x -unexported_symbol _globby \
86 # RUN: -undefined dynamic_lookup
88 # RUN: %lld %t/main.o -o %t/strip_all_unexport_one.out \
89 # RUN: -non_global_symbols_strip_list %t/globby.txt \
90 # RUN: -non_global_symbols_strip_list %t/foo.txt \
91 # RUN: -non_global_symbols_strip_list %t/bar.txt \
92 # RUN: -unexported_symbol _globby \
93 # RUN: -undefined dynamic_lookup
95 # RUN: llvm-nm %t/strip_x_unexport_one.out | FileCheck --check-prefix STRIP-UNEXP %s
96 # RUN: llvm-nm %t/strip_all_unexport_one.out | FileCheck --check-prefix STRIP-UNEXP %s
98 ## -unexported_symbol made _globby a local, therefore it should be stripped by -x too
99 # STRIP-UNEXP: T __mh_execute_header
100 # STRIP-UNEXP-DAG: T _main
101 # STRIP-UNEXP-DAG: U dyld_stub_binder
102 # STRIP-UNEXP-EMPTY:
104 ## Test interactions of -non_global_symbols_strip_list and unexported_symbol.
105 # RUN: %lld %t/main.o -undefined dynamic_lookup -o %t/no_strip_unexport.out \
106 # RUN: -non_global_symbols_no_strip_list %t/globby.txt \
107 # RUN: -unexported_symbol _globby
109 # RUN: llvm-nm %t/no_strip_unexport.out | FileCheck --check-prefix NOSTRIP-UNEXP %s
111 # NOSTRIP-UNEXP: T __mh_execute_header
112 # NOSTRIP-UNEXP-DAG: T _main
113 # NOSTRIP-UNEXP-DAG: t _globby
114 # NOSTRIP-UNEXP-DAG: U dyld_stub_binder
115 # NOSTRIP-UNEXP-EMPTY:
117 #--- foo.txt
118 _foo
120 #--- bar.txt
121 _bar
123 #--- globby.txt
124 _globby
126 #--- main.s
127 .globl _main
128 .globl _globby
130 _foo:
133 _bar:
136 _baz:
139 _main:
140 callq _foo
143 _globby: