xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/keep-only-section.test (revision 55c81d4282c5da0189711261a11537bc8a7fe85c)
1*55c81d42SFangrui Song# RUN: yaml2obj %s -o %t
2298ea3f5SJordan Rupprecht# RUN: llvm-objcopy --keep-section=.test2 --only-section=.test %t %t2
3298ea3f5SJordan Rupprecht# RUN: llvm-objcopy -j .test --keep-section=.test2 %t %t3
4298ea3f5SJordan Rupprecht# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s
585985ed3SJake Ehrlich# RUN: diff %t2 %t3
6f324f6dcSEugene Leviant# RUN: llvm-objcopy --regex --keep-section='^.test$'  --only-section='^.test[2-3]+$' %t %t4
7f324f6dcSEugene Leviant# RUN: llvm-readobj --file-headers --sections %t4 | FileCheck %s --check-prefix=REGEX
885985ed3SJake Ehrlich
985985ed3SJake Ehrlich!ELF
1085985ed3SJake EhrlichFileHeader:
1185985ed3SJake Ehrlich  Class:           ELFCLASS64
1285985ed3SJake Ehrlich  Data:            ELFDATA2LSB
1385985ed3SJake Ehrlich  Type:            ET_REL
1485985ed3SJake Ehrlich  Machine:         EM_X86_64
1585985ed3SJake EhrlichSections:
1685985ed3SJake Ehrlich  - Name:            .test
1785985ed3SJake Ehrlich    Type:            SHT_PROGBITS
1885985ed3SJake Ehrlich  - Name:            .test2
1985985ed3SJake Ehrlich    Type:            SHT_PROGBITS
2085985ed3SJake Ehrlich  - Name:            .test3
2185985ed3SJake Ehrlich    Type:            SHT_PROGBITS
2285985ed3SJake Ehrlich
232779987dSGeorge Rimar# CHECK: SectionHeaderCount: 4
2485985ed3SJake Ehrlich
2585985ed3SJake Ehrlich# CHECK:     Name: .test
2685985ed3SJake Ehrlich# CHECK:     Name: .test2
2785985ed3SJake Ehrlich# CHECK:     Name: .shstrtab
28f324f6dcSEugene Leviant
292779987dSGeorge Rimar# REGEX: SectionHeaderCount: 5
30f324f6dcSEugene Leviant
31f324f6dcSEugene Leviant# REGEX:     Name: .test
32f324f6dcSEugene Leviant# REGEX:     Name: .test2
33f324f6dcSEugene Leviant# REGEX:     Name: .test3
34f324f6dcSEugene Leviant# REGEX:     Name: .shstrtab
35