145 lines · plain
1# REQUIRES: x862 3# RUN: rm -rf %t; split-file %s %t4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/main.s -o %t/main.o5 6## Check that -non_global_symbols_no_strip_list and -non_global_symbols_strip_list7## 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 %s12 13# CONFLICT: error: cannot use both -non_global_symbols_no_strip_list and -non_global_symbols_strip_list14 15## Check that -x causes none of the local symbols to be emitted.16# RUN: %lld %t/main.o -x -o %t/NO-LOCAL.out17# RUN: llvm-nm %t/NO-LOCAL.out | FileCheck --check-prefix NO-LOCAL %s18 19# NO-LOCAL-NOT: t _foo20# NO-LOCAL-NOT: t _bar21# NO-LOCAL-NOT: t _baz22# NO-LOCAL: T _main23 24## Check that when using -x with -non_global_symbols_no_strip_list, whichever appears25## 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.out27# RUN: llvm-nm %t/x_then_no_strip.out | FileCheck --check-prefix X-NO-STRIP %s28 29# RUN: %lld %t/main.o -non_global_symbols_no_strip_list %t/foo.txt -x -o %t/no_strip_then_x.out30# RUN: llvm-nm %t/no_strip_then_x.out | FileCheck --check-prefix NO-LOCAL %s31 32# X-NO-STRIP-NOT: t _bar33# X-NO-STRIP-DAG: t _foo34# X-NO-STRIP-DAG: T _main35 36## Check that -non_global_symbols_no_strip_list can be specified more than once37## (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.txt41# RUN: llvm-nm %t/no_strip_multi.out | FileCheck --check-prefix NO-STRIP-MULTI %s42 43# NO-STRIP-MULTI-NOT: t _baz44# NO-STRIP-MULTI-DAG: t _foo45# NO-STRIP-MULTI-DAG: t _bar46# NO-STRIP-MULTI-DAG: T _main47 48## Check that when using -x with -non_global_symbols_strip_list, whichever appears49## 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.out51# RUN: llvm-nm %t/x_then_strip.out | FileCheck --check-prefix X-STRIP %s52 53# RUN: %lld %t/main.o -non_global_symbols_strip_list %t/foo.txt -x -o %t/strip_then_x.out54# RUN: llvm-nm %t/no_strip_then_x.out | FileCheck --check-prefix NO-LOCAL %s55 56# X-STRIP-NOT: t _foo57# X-STRIP-DAG: t _bar58# X-STRIP-DAG: t _baz59# X-STRIP-DAG: T _main60 61## Check that -non_global_symbols_strip_list can be specified more than once62## (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.txt66# RUN: llvm-nm %t/strip_multi.out | FileCheck --check-prefix STRIP-MULTI %s67 68# STRIP-MULTI-NOT: t _foo69# STRIP-MULTI-NOT: t _bar70# STRIP-MULTI-DAG: t _baz71# STRIP-MULTI-DAG: T _main72 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_lookup77# RUN: llvm-nm %t/strip_all_export_one.out | FileCheck --check-prefix STRIP-EXP %s78 79# STRIP-EXP: U _foo80# STRIP-EXP: U dyld_stub_binder81# 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_lookup87 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_lookup94 95# RUN: llvm-nm %t/strip_x_unexport_one.out | FileCheck --check-prefix STRIP-UNEXP %s96# RUN: llvm-nm %t/strip_all_unexport_one.out | FileCheck --check-prefix STRIP-UNEXP %s97 98## -unexported_symbol made _globby a local, therefore it should be stripped by -x too99# STRIP-UNEXP: T __mh_execute_header100# STRIP-UNEXP-DAG: T _main101# STRIP-UNEXP-DAG: U dyld_stub_binder102# 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 _globby108 109# RUN: llvm-nm %t/no_strip_unexport.out | FileCheck --check-prefix NOSTRIP-UNEXP %s110 111# NOSTRIP-UNEXP: T __mh_execute_header112# NOSTRIP-UNEXP-DAG: T _main113# NOSTRIP-UNEXP-DAG: t _globby114# NOSTRIP-UNEXP-DAG: U dyld_stub_binder115# NOSTRIP-UNEXP-EMPTY:116 117#--- foo.txt118_foo119 120#--- bar.txt121_bar122 123#--- globby.txt124_globby125 126#--- main.s127.globl _main128.globl _globby129 130_foo:131 ret132 133_bar:134 ret135 136_baz:137 ret138 139_main:140 callq _foo141 ret142 143 _globby:144 ret145