1 ## This test checks that llvm-objcopy accepts glob (or "shell wildcard") syntax
2 ## for the --wildcard (-w) flag correctly.
4 # RUN: yaml2obj --docnum=1 %s -o %t.o
6 ## * matches all characters.
7 # RUN: llvm-objcopy --remove-section='.f*' %t.o %t.glob.o
8 # RUN: llvm-readobj --sections %t.glob.o \
9 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR
11 ## Glob matches are full matches. ("*a" does not match ".bar").
12 # RUN: llvm-objcopy --remove-section='*a' %t.o %t.full.o
13 # RUN: llvm-readobj --sections %t.full.o \
14 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO,BAR
16 ## ? matches one character.
17 # RUN: llvm-objcopy --remove-section='.b?r' %t.o %t.question.o
18 # RUN: llvm-readobj --sections %t.question.o \
19 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
21 ## ! (as a leading character) prevents matches, and is not dependent on
23 # RUN: llvm-objcopy --remove-section='.???' --remove-section='!.f*' \
24 # RUN: %t.o %t.negmatch1.o
25 # RUN: llvm-readobj --sections %t.negmatch1.o \
26 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
27 # RUN: llvm-objcopy --remove-section='!.f*' --remove-section='.???' \
28 # RUN: %t.o %t.negmatch2.o
29 # RUN: llvm-readobj --sections %t.negmatch2.o \
30 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
31 # RUN: llvm-objcopy --remove-section='.???' --remove-section='!.f*' \
32 # RUN: --remove-section='.???' %t.o %t.negmatch3.o
33 # RUN: llvm-readobj --sections %t.negmatch3.o \
34 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
36 ## [a-z] matches a range of characters.
37 # RUN: llvm-objcopy --remove-section='.[a-c][a-a][q-s]' %t.o %t.range.o
38 # RUN: llvm-readobj --sections %t.range.o \
39 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
41 ## [^a-z] or [!a-z] match a negated range of characters.
42 # RUN: llvm-objcopy --remove-section='.[^x]oo' %t.o %t.negrange.1.o
43 # RUN: llvm-readobj --sections %t.negrange.1.o \
44 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR
45 # RUN: llvm-objcopy --remove-section='.[!x]oo' %t.o %t.negrange.2.o
46 # RUN: llvm-readobj --sections %t.negrange.2.o \
47 # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR
62 ## Use a separate test file with special characters for the following tests.
64 # RUN: yaml2obj --docnum=2 %s -o %t.special.o
66 ## \ escapes wildcard characters.
67 # RUN: llvm-objcopy --remove-section='\*' %t.special.o %t.escape.1.o
68 # RUN: llvm-readobj --sections %t.escape.1.o \
69 # RUN: | FileCheck %s --implicit-check-not=Name: \
70 # RUN: --check-prefixes=CHECK,DOT,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO
71 # RUN: llvm-objcopy --remove-section='\?' %t.special.o %t.escape.2.o
72 # RUN: llvm-readobj --sections %t.escape.2.o \
73 # RUN: | FileCheck %s --implicit-check-not=Name: \
74 # RUN: --check-prefixes=CHECK,DOT,ASTERISK,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO
76 ## Special characters are not treated like regular expression characters.
77 # RUN: llvm-objcopy --remove-section='.' %t.special.o %t.dot.o
78 # RUN: llvm-readobj --sections %t.dot.o \
79 # RUN: | FileCheck %s --implicit-check-not=Name: \
80 # RUN: --check-prefixes=CHECK,ASTERISK,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO
82 ## Special characters in character classes are treated literally.
83 ## [*] should not get expanded to [.*], which would match both '.' and '*'
84 # RUN: llvm-objcopy --remove-section='[*]' %t.special.o %t.class.1.o
85 # RUN: llvm-readobj --sections %t.class.1.o \
86 # RUN: | FileCheck %s --implicit-check-not=Name: \
87 # RUN: --check-prefixes=CHECK,DOT,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO
89 ## ] doesn't close the character class as a first character. This glob matches
90 ## a single character which is one of ']xyz'. ']' and 'z' are removed, and more explicitly,
91 ## section 'xyz]' is not removed, i.e. the glob is not interpreted as "an empty
92 ## character class followed by 'xyz]'"
93 # RUN: llvm-objcopy --remove-section='[]xyz]' %t.special.o %t.class.2.o
94 # RUN: llvm-readobj --sections %t.class.2.o \
95 # RUN: | FileCheck %s --implicit-check-not=Name: \
96 # RUN: --check-prefixes=CHECK,DOT,ASTERISK,QUESTION,LEFT-BRACKET,INVALID-GLOB,XYZ,FOO
98 ## An invalid glob expression is interpreted as a literal instead.
99 # RUN: llvm-objcopy --remove-section='][]' %t.special.o %t.class.3.o 2>&1 \
100 # RUN: | FileCheck %s --check-prefix=WARN
101 # RUN: llvm-readobj --sections %t.class.3.o \
102 # RUN: | FileCheck %s --implicit-check-not=Name: \
103 # RUN: --check-prefixes=CHECK,DOT,ASTERISK,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,Z,XYZ,FOO
134 # WARN: warning: invalid glob pattern, unmatched '['
141 # LEFT-BRACKET: Name: [
142 # RIGHT-BRACKET: Name: ]
143 # INVALID-GLOB: Name: ][]
149 # CHECK: Name: .symtab
150 # CHECK: Name: .strtab
151 # CHECK: Name: .shstrtab