1 ## This test checks basic functionality of glob (or "shell wildcard") matching,
2 ## as well as verifying all the relevant flags in llvm-objcopy and llvm-strip
3 ## are configured correctly.
4 ## For more detailed syntax tests, see wildcard-syntax.test.
6 # RUN: yaml2obj %s > %t.o
8 ## Check that --regex and --wildcard cannot be used together.
9 # RUN: not llvm-objcopy --regex --wildcard %t.o %t.err.o 2>&1 \
10 # RUN: | FileCheck %s --check-prefix=ERR
11 # RUN: not llvm-strip --regex --wildcard %t.o -o %t.err.o 2>&1 \
12 # RUN: | FileCheck %s --check-prefix=ERR
14 # ERR: error: --regex and --wildcard are incompatible
16 ## Check that section removal flags default to glob matches.
19 # RUN: llvm-objcopy --strip-all --keep-section='.f*' %t.o %t.ksec.1.o
20 # RUN: llvm-readobj --sections %t.ksec.1.o \
21 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,SEC,FOO-SEC
22 # RUN: llvm-strip --strip-all --keep-section='.f*' %t.o -o %t.ksec.2.o
23 # RUN: cmp %t.ksec.1.o %t.ksec.2.o
26 # RUN: llvm-objcopy --strip-all --only-section='.f*' %t.o %t.osec.1.o
27 # RUN: llvm-readobj --sections %t.osec.1.o \
28 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,SEC,FOO-SEC
31 # RUN: llvm-objcopy --strip-debug --remove-section='.s??tab' %t.o %t.rsec.1.o
32 # RUN: llvm-readobj --sections %t.rsec.1.o \
33 # RUN: | FileCheck %s --implicit-check-not=Name: \
34 # RUN: --check-prefixes=CHECK,SEC,FOO-SEC,BAR-SEC
35 # RUN: llvm-strip --strip-debug --remove-section='.s??tab' %t.o -o %t.rsec.2.o
36 # RUN: cmp %t.rsec.1.o %t.rsec.2.o
38 ## Check that symbol removal options default to literal matches. Adding -w
39 ## enables glob support for these options.
41 ## --globalize-symbol:
42 # RUN: llvm-objcopy --globalize-symbol='*' %t.o %t.globsym.1.o
43 # RUN: llvm-readobj --symbols %t.globsym.1.o \
44 # RUN: | FileCheck %s --implicit-check-not=Name: \
45 # RUN: --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM
47 # RUN: llvm-objcopy -w --globalize-symbol='*' %t.o %t.globsym.2.o
48 # RUN: llvm-readobj --symbols %t.globsym.2.o \
49 # RUN: | FileCheck %s --implicit-check-not=Name: \
50 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
53 # RUN: llvm-objcopy --discard-all --keep-symbol='f*' %t.o %t.ksym.1.o
54 # RUN: llvm-readobj --symbols %t.ksym.1.o \
55 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK
56 # RUN: llvm-strip --discard-all --keep-symbol='f*' %t.o -o %t.ksym.2.o
57 # RUN: cmp %t.ksym.1.o %t.ksym.2.o
59 # RUN: llvm-objcopy --discard-all -w --keep-symbol='f*' %t.o %t.ksym.3.o
60 # RUN: llvm-readobj --symbols %t.ksym.3.o \
61 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM
62 # RUN: llvm-strip --discard-all -w --keep-symbol='f*' %t.o -o %t.ksym.4.o
63 # RUN: cmp %t.ksym.3.o %t.ksym.4.o
66 ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
67 # RUN: llvm-objcopy --localize-symbol='*' %t.globsym.2.o %t.localsym.1.o
68 # RUN: llvm-readobj --symbols %t.localsym.1.o \
69 # RUN: | FileCheck %s --implicit-check-not=Name: \
70 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
72 # RUN: llvm-objcopy -w --localize-symbol='*' %t.globsym.2.o %t.localsym.2.o
73 # RUN: llvm-readobj --symbols %t.localsym.2.o \
74 # RUN: | FileCheck %s --implicit-check-not=Name: \
75 # RUN: --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM
78 # RUN: llvm-objcopy --strip-symbol='f*' %t.o %t.stripsym.1.o
79 # RUN: llvm-readobj --symbols %t.stripsym.1.o \
80 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM,BAR-SYM
81 # RUN: llvm-strip --strip-symbol='f*' %t.o -o %t.stripsym.2.o
82 # RUN: cmp %t.stripsym.1.o %t.stripsym.2.o
84 # RUN: llvm-objcopy -w --strip-symbol='f*' %t.o %t.stripsym.3.o
85 # RUN: llvm-readobj --symbols %t.stripsym.3.o \
86 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM
87 # RUN: llvm-strip -w --strip-symbol='f*' %t.o -o %t.stripsym.4.o
88 # RUN: cmp %t.stripsym.3.o %t.stripsym.4.o
90 ## --strip-unneeded-symbol:
91 # RUN: llvm-objcopy --strip-unneeded-symbol='f*' %t.o %t.stripunsym.1.o
92 # RUN: llvm-readobj --symbols %t.stripunsym.1.o \
93 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM,BAR-SYM
95 # RUN: llvm-objcopy -w --strip-unneeded-symbol='f*' %t.o %t.stripunsym.2.o
96 # RUN: llvm-readobj --symbols %t.stripunsym.2.o \
97 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM
100 ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
101 # RUN: llvm-objcopy --weaken-symbol='*' %t.globsym.2.o %t.weaksym.1.o
102 # RUN: llvm-readobj --symbols %t.weaksym.1.o \
103 # RUN: | FileCheck %s --implicit-check-not=Name: \
104 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
106 # RUN: llvm-objcopy -w --weaken-symbol='*' %t.globsym.2.o %t.weaksym.2.o
107 # RUN: llvm-readobj --symbols %t.weaksym.2.o \
108 # RUN: | FileCheck %s --implicit-check-not=Name: \
109 # RUN: --check-prefixes=CHECK,WEAK,FOO-SYM,BAR-SYM
111 ## --keep-global-symbol:
112 ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
113 # RUN: llvm-objcopy --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.1.o
114 # RUN: llvm-readobj --symbols %t.keepgsym.1.o \
115 # RUN: | FileCheck %s --implicit-check-not=Name: \
116 # RUN: --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM
118 # RUN: llvm-objcopy -w --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.2.o
119 # RUN: llvm-readobj --symbols %t.keepgsym.2.o \
120 # RUN: | FileCheck %s --implicit-check-not=Name: \
121 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
123 ## Check that -w is accepted as an alias for --wildcard.
124 # RUN: llvm-objcopy --wildcard --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.3.o
125 # RUN: cmp %t.keepgsym.2.o %t.keepgsym.3.o
130 # FOO-SEC: Name: .foo
133 # GLOBAL: Binding: Global
134 # WEAK: Binding: Weak
135 # LOCAL: Binding: Local
137 # BAR-SEC: Name: .bar
139 # GLOBAL: Binding: Global
140 # WEAK: Binding: Weak
141 # LOCAL: Binding: Local
143 # SEC: Name: .shstrtab