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 -o %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 # RUN: echo 'f*' > %t-fstar.txt
67 # RUN: llvm-objcopy --discard-all --keep-symbols=%t-fstar.txt %t.o %t.ksym.5.o
68 # RUN: cmp %t.ksym.5.o %t.ksym.1.o
70 # RUN: llvm-objcopy --discard-all -w --keep-symbols=%t-fstar.txt %t.o %t.ksym.6.o
71 # RUN: cmp %t.ksym.6.o %t.ksym.3.o
74 ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
75 # RUN: llvm-objcopy --localize-symbol='*' %t.globsym.2.o %t.localsym.1.o
76 # RUN: llvm-readobj --symbols %t.localsym.1.o \
77 # RUN: | FileCheck %s --implicit-check-not=Name: \
78 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
80 # RUN: llvm-objcopy -w --localize-symbol='*' %t.globsym.2.o %t.localsym.2.o
81 # RUN: llvm-readobj --symbols %t.localsym.2.o \
82 # RUN: | FileCheck %s --implicit-check-not=Name: \
83 # RUN: --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM
85 ## --localize-symbols:
86 # RUN: echo '*' > %t-star.txt
87 # RUN: llvm-objcopy --localize-symbols=%t-star.txt %t.globsym.2.o %t.localsym.3.o
88 # RUN: cmp %t.localsym.3.o %t.localsym.1.o
90 # RUN: llvm-objcopy -w --localize-symbols=%t-star.txt %t.globsym.2.o %t.localsym.4.o
91 # RUN: cmp %t.localsym.4.o %t.localsym.2.o
94 # RUN: llvm-objcopy --strip-symbol='f*' %t.o %t.stripsym.1.o
95 # RUN: llvm-readobj --symbols %t.stripsym.1.o \
96 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM,BAR-SYM
97 # RUN: llvm-strip --strip-symbol='f*' %t.o -o %t.stripsym.2.o
98 # RUN: cmp %t.stripsym.1.o %t.stripsym.2.o
100 # RUN: llvm-objcopy -w --strip-symbol='f*' %t.o %t.stripsym.3.o
101 # RUN: llvm-readobj --symbols %t.stripsym.3.o \
102 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM
103 # RUN: llvm-strip -w --strip-symbol='f*' %t.o -o %t.stripsym.4.o
104 # RUN: cmp %t.stripsym.3.o %t.stripsym.4.o
107 # RUN: llvm-objcopy --strip-symbols=%t-fstar.txt %t.o %t.stripsym.5.o
108 # RUN: cmp %t.stripsym.5.o %t.stripsym.1.o
110 # RUN: llvm-objcopy -w --strip-symbols=%t-fstar.txt %t.o %t.stripsym.6.o
111 # RUN: cmp %t.stripsym.6.o %t.stripsym.3.o
113 ## --strip-unneeded-symbol:
114 # RUN: llvm-objcopy --strip-unneeded-symbol='f*' %t.o %t.stripunsym.1.o
115 # RUN: llvm-readobj --symbols %t.stripunsym.1.o \
116 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM,BAR-SYM
118 # RUN: llvm-objcopy -w --strip-unneeded-symbol='f*' %t.o %t.stripunsym.2.o
119 # RUN: llvm-readobj --symbols %t.stripunsym.2.o \
120 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM
122 ## --strip-unneded-symbols:
123 # RUN: llvm-objcopy --strip-unneeded-symbols=%t-fstar.txt %t.o %t.stripunsym.3.o
124 # RUN: cmp %t.stripunsym.3.o %t.stripunsym.1.o
126 # RUN: llvm-objcopy -w --strip-unneeded-symbols=%t-fstar.txt %t.o %t.stripunsym.4.o
127 # RUN: cmp %t.stripunsym.4.o %t.stripunsym.2.o
130 ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
131 # RUN: llvm-objcopy --weaken-symbol='*' %t.globsym.2.o %t.weaksym.1.o
132 # RUN: llvm-readobj --symbols %t.weaksym.1.o \
133 # RUN: | FileCheck %s --implicit-check-not=Name: \
134 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
136 # RUN: llvm-objcopy -w --weaken-symbol='*' %t.globsym.2.o %t.weaksym.2.o
137 # RUN: llvm-readobj --symbols %t.weaksym.2.o \
138 # RUN: | FileCheck %s --implicit-check-not=Name: \
139 # RUN: --check-prefixes=CHECK,WEAK,FOO-SYM,BAR-SYM
142 # RUN: llvm-objcopy --weaken-symbols=%t-star.txt %t.globsym.2.o %t.weaksym.3.o
143 # RUN: cmp %t.weaksym.3.o %t.weaksym.1.o
145 # RUN: llvm-objcopy -w --weaken-symbols=%t-star.txt %t.globsym.2.o %t.weaksym.4.o
146 # RUN: cmp %t.weaksym.4.o %t.weaksym.2.o
148 ## --keep-global-symbol:
149 ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
150 # RUN: llvm-objcopy --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.1.o
151 # RUN: llvm-readobj --symbols %t.keepgsym.1.o \
152 # RUN: | FileCheck %s --implicit-check-not=Name: \
153 # RUN: --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM
155 # RUN: llvm-objcopy -w --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.2.o
156 # RUN: llvm-readobj --symbols %t.keepgsym.2.o \
157 # RUN: | FileCheck %s --implicit-check-not=Name: \
158 # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM
160 ## --keep-global-symbols:
161 # RUN: llvm-objcopy --keep-global-symbols=%t-star.txt %t.globsym.2.o %t.keepgsym.3.o
162 # RUN: cmp %t.keepgsym.3.o %t.keepgsym.1.o
164 # RUN: llvm-objcopy -w --keep-global-symbols=%t-star.txt %t.globsym.2.o %t.keepgsym.4.o
165 # RUN: cmp %t.keepgsym.4.o %t.keepgsym.2.o
167 ## Check that -w is accepted as an alias for --wildcard.
168 # RUN: llvm-objcopy --wildcard --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.5.o
169 # RUN: cmp %t.keepgsym.2.o %t.keepgsym.5.o
174 # FOO-SEC: Name: .foo
177 # GLOBAL: Binding: Global
178 # WEAK: Binding: Weak
179 # LOCAL: Binding: Local
181 # BAR-SEC: Name: .bar
183 # GLOBAL: Binding: Global
184 # WEAK: Binding: Weak
185 # LOCAL: Binding: Local
187 # SEC: Name: .shstrtab