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
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
## This test checks basic functionality of glob (or "shell wildcard") matching,
## as well as verifying all the relevant flags in llvm-objcopy and llvm-strip
## are configured correctly.
## For more detailed syntax tests, see wildcard-syntax.test.

# RUN: yaml2obj %s > %t.o

## Check that --regex and --wildcard cannot be used together.
# RUN: not llvm-objcopy --regex --wildcard %t.o %t.err.o 2>&1 \
# RUN:   | FileCheck %s --check-prefix=ERR
# RUN: not llvm-strip --regex --wildcard %t.o -o %t.err.o 2>&1 \
# RUN:   | FileCheck %s --check-prefix=ERR

# ERR: error: --regex and --wildcard are incompatible

## Check that section removal flags default to glob matches.

## --keep-section:
# RUN: llvm-objcopy --strip-all --keep-section='.f*' %t.o %t.ksec.1.o
# RUN: llvm-readobj --sections %t.ksec.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,SEC,FOO-SEC
# RUN: llvm-strip --strip-all --keep-section='.f*' %t.o -o %t.ksec.2.o
# RUN: cmp %t.ksec.1.o %t.ksec.2.o

## --only-section:
# RUN: llvm-objcopy --strip-all --only-section='.f*' %t.o %t.osec.1.o
# RUN: llvm-readobj --sections %t.osec.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,SEC,FOO-SEC

## --remove-section:
# RUN: llvm-objcopy --strip-debug --remove-section='.s??tab' %t.o %t.rsec.1.o
# RUN: llvm-readobj --sections %t.rsec.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,SEC,FOO-SEC,BAR-SEC
# RUN: llvm-strip --strip-debug --remove-section='.s??tab' %t.o -o %t.rsec.2.o
# RUN: cmp %t.rsec.1.o %t.rsec.2.o

## Check that symbol removal options default to literal matches. Adding -w
## enables glob support for these options.

## --globalize-symbol:
# RUN: llvm-objcopy --globalize-symbol='*' %t.o %t.globsym.1.o
# RUN: llvm-readobj --symbols %t.globsym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM

# RUN: llvm-objcopy -w --globalize-symbol='*' %t.o %t.globsym.2.o
# RUN: llvm-readobj --symbols %t.globsym.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM

## --keep-symbol:
# RUN: llvm-objcopy --discard-all --keep-symbol='f*' %t.o %t.ksym.1.o
# RUN: llvm-readobj --symbols %t.ksym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK
# RUN: llvm-strip --discard-all --keep-symbol='f*' %t.o -o %t.ksym.2.o
# RUN: cmp %t.ksym.1.o %t.ksym.2.o

# RUN: llvm-objcopy --discard-all -w --keep-symbol='f*' %t.o %t.ksym.3.o
# RUN: llvm-readobj --symbols %t.ksym.3.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM
# RUN: llvm-strip --discard-all -w --keep-symbol='f*' %t.o -o %t.ksym.4.o
# RUN: cmp %t.ksym.3.o %t.ksym.4.o

## --localize-symbol:
## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
# RUN: llvm-objcopy --localize-symbol='*' %t.globsym.2.o %t.localsym.1.o
# RUN: llvm-readobj --symbols %t.localsym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM

# RUN: llvm-objcopy -w --localize-symbol='*' %t.globsym.2.o %t.localsym.2.o
# RUN: llvm-readobj --symbols %t.localsym.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM

## --strip-symbol:
# RUN: llvm-objcopy --strip-symbol='f*' %t.o %t.stripsym.1.o
# RUN: llvm-readobj --symbols %t.stripsym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM,BAR-SYM
# RUN: llvm-strip --strip-symbol='f*' %t.o -o %t.stripsym.2.o
# RUN: cmp %t.stripsym.1.o %t.stripsym.2.o

# RUN: llvm-objcopy -w --strip-symbol='f*' %t.o %t.stripsym.3.o
# RUN: llvm-readobj --symbols %t.stripsym.3.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM
# RUN: llvm-strip -w --strip-symbol='f*' %t.o -o %t.stripsym.4.o
# RUN: cmp %t.stripsym.3.o %t.stripsym.4.o

## --strip-unneeded-symbol:
# RUN: llvm-objcopy --strip-unneeded-symbol='f*' %t.o %t.stripunsym.1.o
# RUN: llvm-readobj --symbols %t.stripunsym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,FOO-SYM,BAR-SYM

# RUN: llvm-objcopy -w --strip-unneeded-symbol='f*' %t.o %t.stripunsym.2.o
# RUN: llvm-readobj --symbols %t.stripunsym.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM

## --weaken-symbol:
## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
# RUN: llvm-objcopy --weaken-symbol='*' %t.globsym.2.o %t.weaksym.1.o
# RUN: llvm-readobj --symbols %t.weaksym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM

# RUN: llvm-objcopy -w --weaken-symbol='*' %t.globsym.2.o %t.weaksym.2.o
# RUN: llvm-readobj --symbols %t.weaksym.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,WEAK,FOO-SYM,BAR-SYM

## --keep-global-symbol:
## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global.
# RUN: llvm-objcopy --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.1.o
# RUN: llvm-readobj --symbols %t.keepgsym.1.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM

# RUN: llvm-objcopy -w --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.2.o
# RUN: llvm-readobj --symbols %t.keepgsym.2.o \
# RUN:   | FileCheck %s --implicit-check-not=Name: \
# RUN:       --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM

## Check that -w is accepted as an alias for --wildcard.
# RUN: llvm-objcopy --wildcard --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.3.o
# RUN: cmp %t.keepgsym.2.o %t.keepgsym.3.o

# CHECK:   LoadName:
# CHECK:   Name: (0)

# FOO-SEC: Name: .foo

# FOO-SYM: Name: foo
# GLOBAL:  Binding: Global
# WEAK:    Binding: Weak
# LOCAL:   Binding: Local

# BAR-SEC: Name: .bar
# BAR-SYM: Name: bar
# GLOBAL:  Binding: Global
# WEAK:    Binding: Weak
# LOCAL:   Binding: Local

# SEC:     Name: .shstrtab

!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:
  - Name:    foo
    Type:    STT_FUNC
    Section: .foo
  - Name:    bar
    Type:    STT_FUNC
    Section: .foo