1# REQUIRES: x86 2 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 5 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 12 13# CONFLICT: error: cannot use both -non_global_symbols_no_strip_list and -non_global_symbols_strip_list 14 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 18 19# NO-LOCAL-NOT: t _foo 20# NO-LOCAL-NOT: t _bar 21# NO-LOCAL-NOT: t _baz 22# NO-LOCAL: T _main 23 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 28 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 31 32# X-NO-STRIP-NOT: t _bar 33# X-NO-STRIP-DAG: t _foo 34# X-NO-STRIP-DAG: T _main 35 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 42 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 47 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 52 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 55 56# X-STRIP-NOT: t _foo 57# X-STRIP-DAG: t _bar 58# X-STRIP-DAG: t _baz 59# X-STRIP-DAG: T _main 60 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 67 68# STRIP-MULTI-NOT: t _foo 69# STRIP-MULTI-NOT: t _bar 70# STRIP-MULTI-DAG: t _baz 71# STRIP-MULTI-DAG: T _main 72 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 78 79# STRIP-EXP: U _foo 80# STRIP-EXP: U dyld_stub_binder 81# STRIP-EXP-EMPTY: 82 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 87 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 94 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 97 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: 103 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 108 109# RUN: llvm-nm %t/no_strip_unexport.out | FileCheck --check-prefix NOSTRIP-UNEXP %s 110 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: 116 117#--- foo.txt 118_foo 119 120#--- bar.txt 121_bar 122 123#--- globby.txt 124_globby 125 126#--- main.s 127.globl _main 128.globl _globby 129 130_foo: 131 ret 132 133_bar: 134 ret 135 136_baz: 137 ret 138 139_main: 140 callq _foo 141 ret 142 143 _globby: 144 ret 145