104 lines
3.1 KiB
Plaintext
104 lines
3.1 KiB
Plaintext
# RUN: yaml2obj %s -o %t
|
|
# RUN: llvm-objcopy %t %t1 \
|
|
# RUN: --rename-section=.tst1.foo=.tst1.ren.foo \
|
|
# RUN: --rename-section=.tst1.bar=.tst1.ren.bar \
|
|
# RUN: --rename-section=.tst2.foo=.tst2.ren.foo \
|
|
# RUN: --rename-section=.tst3.foo=.tst3.ren.foo \
|
|
# RUN: --rename-section=.tst4.foo=.tst4.ren.foo \
|
|
# RUN: --rename-section=.rel.tst4.foo=.tst4.ren.foo.rel \
|
|
# RUN: --rename-section=.tst6.got.plt=.tst6.ren.got.plt \
|
|
# RUN: --rename-section=.tst7.rela.plt=.tst7.ren.rela.plt
|
|
# RUN: llvm-readobj --sections %t1 | FileCheck %s
|
|
|
|
!ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
|
|
## Test 1. When a section is renamed, its relocation section should be renamed
|
|
## similarly.
|
|
# CHECK: Name: .tst1.ren.foo{{ }}
|
|
# CHECK: Name: .rel.tst1.ren.foo{{ }}
|
|
# CHECK: Name: .rela.tst1.ren.bar{{ }}
|
|
# CHECK: Name: .tst1.ren.bar{{ }}
|
|
- Name: .tst1.foo
|
|
Type: SHT_PROGBITS
|
|
- Name: .rel.tst1.foo
|
|
Type: SHT_REL
|
|
Info: .tst1.foo
|
|
- Name: .rela.tst1.bar
|
|
Type: SHT_RELA
|
|
Info: .tst1.bar
|
|
- Name: .tst1.bar
|
|
Type: SHT_PROGBITS
|
|
|
|
## Test 2. A relocation section should be renamed together with its target
|
|
## section even if its name does not follow the typical pattern.
|
|
# CHECK: Name: .tst2.ren.foo{{ }}
|
|
# CHECK: Name: .rel.tst2.ren.foo{{ }}
|
|
- Name: .tst2.foo
|
|
Type: SHT_PROGBITS
|
|
- Name: .tst2.foo.rel
|
|
Type: SHT_REL
|
|
Info: .tst2.foo
|
|
|
|
## Test 3. A relocation section should not be renamed if an unrelated section
|
|
## with the same common name is renamed.
|
|
## Note that '.rel.tst3.foo' targets '.tst3.bar', not '.tst3.foo'
|
|
# CHECK: Name: .tst3.ren.foo{{ }}
|
|
# CHECK: Name: .tst3.bar{{ }}
|
|
# CHECK: Name: .rel.tst3.foo{{ }}
|
|
- Name: .tst3.foo
|
|
Type: SHT_PROGBITS
|
|
- Name: .tst3.bar
|
|
Type: SHT_PROGBITS
|
|
- Name: .rel.tst3.foo
|
|
Type: SHT_REL
|
|
Info: .tst3.bar
|
|
|
|
## Test 4. A relocation section can be renamed with an explicit --rename-section
|
|
## command. Explicit renaming overrides implicit one.
|
|
# CHECK: Name: .tst4.ren.foo{{ }}
|
|
# CHECK: Name: .tst4.ren.foo.rel{{ }}
|
|
- Name: .tst4.foo
|
|
Type: SHT_PROGBITS
|
|
- Name: .rel.tst4.foo
|
|
Type: SHT_REL
|
|
Info: .tst4.foo
|
|
|
|
## Test 5. Should not rename a relocation section if it or its target are not
|
|
## specified in --rename-section.
|
|
## Note that this diverges from GNU objcopy.
|
|
# CHECK: Name: .tst5.foo{{ }}
|
|
# CHECK: Name: .tst5.foo.rel{{ }}
|
|
- Name: .tst5.foo
|
|
Type: SHT_PROGBITS
|
|
- Name: .tst5.foo.rel
|
|
Type: SHT_REL
|
|
Info: .tst5.foo
|
|
|
|
## Test 6. A dynamic relocation section should not be renamed together with its
|
|
## target section.
|
|
# CHECK: Name: .tst6.rela.plt{{ }}
|
|
# CHECK: Name: .tst6.ren.got.plt{{ }}
|
|
- Name: .tst6.rela.plt
|
|
Type: SHT_RELA
|
|
Flags: [ SHF_ALLOC ]
|
|
Info: .tst6.got.plt
|
|
- Name: .tst6.got.plt
|
|
Type: SHT_PROGBITS
|
|
|
|
## Test 7. A dynamic relocation section can be renamed with an explicit
|
|
## --rename-section command.
|
|
# CHECK: Name: .tst7.ren.rela.plt{{ }}
|
|
# CHECK: Name: .tst7.got.plt{{ }}
|
|
- Name: .tst7.rela.plt
|
|
Type: SHT_RELA
|
|
Flags: [ SHF_ALLOC ]
|
|
Info: .tst7.got.plt
|
|
- Name: .tst7.got.plt
|
|
Type: SHT_PROGBITS
|