xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/regex.test (revision 55c81d4282c5da0189711261a11537bc8a7fe85c)
1*55c81d42SFangrui Song# RUN: yaml2obj %s -o %t
2f324f6dcSEugene Leviant
3f324f6dcSEugene Leviant# No symbol matches, because pattern is implicitly enveloped in '^$'
4f324f6dcSEugene Leviant# RUN: llvm-objcopy --discard-all --regex -K 'ba' %t %t2
5f324f6dcSEugene Leviant# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=REGEX1
6f324f6dcSEugene Leviant
7f324f6dcSEugene Leviant# Symbol 'bar' matches
8f324f6dcSEugene Leviant# RUN: llvm-objcopy --discard-all --regex -K 'ba.*' %t %t3
9f324f6dcSEugene Leviant# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=REGEX2
10f324f6dcSEugene Leviant
11f324f6dcSEugene Leviant# All symbols match
12f324f6dcSEugene Leviant# RUN: llvm-objcopy --discard-all --regex -K '.*ba.*' %t %t4
13f324f6dcSEugene Leviant# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=REGEX3
14f324f6dcSEugene Leviant
15f324f6dcSEugene Leviant# All symbols match
16f324f6dcSEugene Leviant# RUN: llvm-objcopy --discard-all --regex -K '^([a-z]+)*ba.*$' %t %t5
17f324f6dcSEugene Leviant# RUN: cmp %t4 %t5
18f324f6dcSEugene Leviant
19f324f6dcSEugene Leviant!ELF
20f324f6dcSEugene LeviantFileHeader:
21f324f6dcSEugene Leviant  Class:           ELFCLASS64
22f324f6dcSEugene Leviant  Data:            ELFDATA2LSB
23f324f6dcSEugene Leviant  Type:            ET_REL
24f324f6dcSEugene Leviant  Machine:         EM_X86_64
25f324f6dcSEugene LeviantSections:
26f324f6dcSEugene Leviant  - Name:            .text
27f324f6dcSEugene Leviant    Type:            SHT_PROGBITS
28f324f6dcSEugene Leviant    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
29f324f6dcSEugene Leviant    Address:         0x1000
30f324f6dcSEugene Leviant    AddressAlign:    0x0000000000000010
31f324f6dcSEugene Leviant    Size:            64
32f324f6dcSEugene LeviantSymbols:
33f324f6dcSEugene Leviant  - Name:     foobaz
34f324f6dcSEugene Leviant    Type:     STT_FUNC
35f324f6dcSEugene Leviant    Section:  .text
36f324f6dcSEugene Leviant    Value:    0x1000
37f324f6dcSEugene Leviant    Size:     8
38f324f6dcSEugene Leviant  - Name:     bar
39f324f6dcSEugene Leviant    Type:     STT_FUNC
40f324f6dcSEugene Leviant    Section:  .text
41f324f6dcSEugene Leviant    Value:    0x1008
42f324f6dcSEugene Leviant    Size:     8
43f324f6dcSEugene Leviant  - Name:     rebar
44f324f6dcSEugene Leviant    Type:     STT_FUNC
45f324f6dcSEugene Leviant    Section:  .text
46f324f6dcSEugene Leviant    Value:    0x1010
47f324f6dcSEugene Leviant    Size:     8
48f324f6dcSEugene Leviant
4998e3954fSDon Hinton#REGEX1:     Symbols [
5098e3954fSDon Hinton#REGEX1-NOT:   Name: foobaz
5198e3954fSDon Hinton#REGEX1-NOT:   Name: bar
5298e3954fSDon Hinton#REGEX1-NOT:   Name: rebar
5398e3954fSDon Hinton#REGEX1:     ]
54f324f6dcSEugene Leviant
5598e3954fSDon Hinton#REGEX2:     Symbols [
5698e3954fSDon Hinton#REGEX2-NOT:   Name: foobaz
5798e3954fSDon Hinton#REGEX2:       Name: bar
5898e3954fSDon Hinton#REGEX2-NOT:   Name: rebar
5998e3954fSDon Hinton#REGEX2:     ]
60f324f6dcSEugene Leviant
6198e3954fSDon Hinton#REGEX3: Symbols [
6298e3954fSDon Hinton#REGEX3:   Name: foobaz
6398e3954fSDon Hinton#REGEX3:   Name: bar
6498e3954fSDon Hinton#REGEX3:   Name: rebar
6598e3954fSDon Hinton#REGEX3: ]
66