reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
## This test checks that llvm-objcopy accepts glob (or "shell wildcard") syntax
## for the --wildcard (-w) flag correctly.

# RUN: yaml2obj --docnum=1 %s > %t.o

## * matches all characters.
# RUN: llvm-objcopy --remove-section='.f*' %t.o %t.glob.o
# RUN: llvm-readobj --sections %t.glob.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR

## Glob matches are full matches. ("*a" does not match ".bar").
# RUN: llvm-objcopy --remove-section='*a' %t.o %t.full.o
# RUN: llvm-readobj --sections %t.full.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO,BAR

## ? matches one character.
# RUN: llvm-objcopy --remove-section='.b?r' %t.o %t.question.o
# RUN: llvm-readobj --sections %t.question.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO

## ! (as a leading character) prevents matches, and is not dependent on
## ordering.
# RUN: llvm-objcopy --remove-section='.???' --remove-section='!.f*' \
# RUN:   %t.o %t.negmatch1.o
# RUN: llvm-readobj --sections %t.negmatch1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
# RUN: llvm-objcopy --remove-section='!.f*' --remove-section='.???' \
# RUN:   %t.o %t.negmatch2.o
# RUN: llvm-readobj --sections %t.negmatch2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO
# RUN: llvm-objcopy --remove-section='.???' --remove-section='!.f*' \
# RUN:   --remove-section='.???' %t.o %t.negmatch3.o
# RUN: llvm-readobj --sections %t.negmatch3.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO

## [a-z] matches a range of characters.
# RUN: llvm-objcopy --remove-section='.[a-c][a-a][q-s]' %t.o %t.range.o
# RUN: llvm-readobj --sections %t.range.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO

## [^a-z] or [!a-z] match a negated range of characters.
# RUN: llvm-objcopy --remove-section='.[^x]oo' %t.o %t.negrange.1.o
# RUN: llvm-readobj --sections %t.negrange.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR
# RUN: llvm-objcopy --remove-section='.[!x]oo' %t.o %t.negrange.2.o
# RUN: llvm-readobj --sections %t.negrange.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
  - Name: .bar
    Type: SHT_PROGBITS
Symbols: []

## Use a separate test file with special characters for the following tests.

# RUN: yaml2obj --docnum=2 %s > %t.special.o

## \ escapes wildcard characters.
# RUN: llvm-objcopy --remove-section='\*' %t.special.o %t.escape.1.o
# RUN: llvm-readobj --sections %t.escape.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:   --check-prefixes=CHECK,DOT,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO
# RUN: llvm-objcopy --remove-section='\?' %t.special.o %t.escape.2.o
# RUN: llvm-readobj --sections %t.escape.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:   --check-prefixes=CHECK,DOT,ASTERISK,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO

## Special characters are not treated like regular expression characters.
# RUN: llvm-objcopy --remove-section='.' %t.special.o %t.dot.o
# RUN: llvm-readobj --sections %t.dot.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:   --check-prefixes=CHECK,ASTERISK,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO

## Special characters in character classes are treated literally.
## [*] should not get expanded to [.*], which would match both '.' and '*'
# RUN: llvm-objcopy --remove-section='[*]' %t.special.o %t.class.1.o
# RUN: llvm-readobj --sections %t.class.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:   --check-prefixes=CHECK,DOT,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,INVALID-GLOB,Z,XYZ,FOO

## ] doesn't close the character class as a first character. This glob matches
## a single character which is one of ']xyz'. ']' and 'z' are removed, and more explicitly,
## section 'xyz]' is not removed, i.e. the glob is not interpreted as "an empty
## character class followed by 'xyz]'"
# RUN: llvm-objcopy --remove-section='[]xyz]' %t.special.o %t.class.2.o
# RUN: llvm-readobj --sections %t.class.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:   --check-prefixes=CHECK,DOT,ASTERISK,QUESTION,LEFT-BRACKET,INVALID-GLOB,XYZ,FOO

## An invalid glob expression is interpreted as a literal instead.
# RUN: llvm-objcopy --remove-section='][]' %t.special.o %t.class.3.o 2>&1 \
# RUN:   | FileCheck %s --check-prefix=WARN
# RUN: llvm-readobj --sections %t.class.3.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:   --check-prefixes=CHECK,DOT,ASTERISK,QUESTION,LEFT-BRACKET,RIGHT-BRACKET,Z,XYZ,FOO

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64
Sections:
  - Name: .
    Type: SHT_PROGBITS
  - Name: '*'
    Type: SHT_PROGBITS
  - Name: '?'
    Type: SHT_PROGBITS
  - Name: '['
    Type: SHT_PROGBITS
  - Name: ']'
    Type: SHT_PROGBITS
  - Name: '][]'
    Type: SHT_PROGBITS
  - Name: z
    Type: SHT_PROGBITS
  - Name: 'xyz]'
    Type: SHT_PROGBITS
  - Name: '[]xyz]'
    Type: SHT_PROGBITS
  - Name: .foo
    Type: SHT_PROGBITS
Symbols: []

# WARN: warning: invalid glob pattern: ][]

# CHECK: LoadName:
# CHECK:         Name: (0)
# DOT:           Name: .
# ASTERISK:      Name: *
# QUESTION:      Name: ?
# LEFT-BRACKET:  Name: [
# RIGHT-BRACKET: Name: ]
# INVALID-GLOB:  Name: ][]
# Z:             Name: z
# XYZ:           Name: xyz]
# XYZ:           Name: []xyz]
# FOO:           Name: .foo
# BAR:           Name: .bar
# CHECK:         Name: .symtab
# CHECK:         Name: .strtab
# CHECK:         Name: .shstrtab