xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/rename-section.test (revision 1562e4552cd1b3d2eadd956c966f8a60e928b8ca)
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy --rename-section=.foo=.bar %t %t2
3# RUN: llvm-readobj --file-headers --sections --section-data %t2 | FileCheck %s
4# RUN: not llvm-objcopy --rename-section=.foo.bar --rename-section=.foo=.other %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT
5# RUN: not llvm-objcopy --rename-section=.foo=.bar --rename-section=.foo=.other %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-RENAMES
6
7## Section renames don't chain:
8# RUN: llvm-objcopy --rename-section=.foo=.bar --rename-section=.bar=.baz %t %t3
9# RUN: cmp %t2 %t3
10
11!ELF
12FileHeader:
13  Class:           ELFCLASS64
14  Data:            ELFDATA2LSB
15  Type:            ET_REL
16  Machine:         EM_X86_64
17Sections:
18  - Name:            .foo
19    Type:            SHT_PROGBITS
20    Flags:           [ SHF_ALLOC ]
21    Content:        "c3c3c3c3"
22
23# CHECK: SectionHeaderCount: 4
24
25# CHECK: Name: .bar
26# CHECK: SectionData (
27# CHECK-NEXT:   0000: C3C3C3C3
28# CHECK-NEXT: )
29# CHECK: Name: .strtab
30# CHECK: Name: .shstrtab
31
32#BAD-FORMAT: bad format for --rename-section: missing '='
33#MULTIPLE-RENAMES: multiple renames of section '.foo'
34