brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · d1f7ce5 Raw
104 lines · plain
1# RUN: yaml2obj %s -o %t2# RUN: llvm-objcopy %t %t1 \3# RUN:    --rename-section=.tst1.foo=.tst1.ren.foo \4# RUN:    --rename-section=.tst1.bar=.tst1.ren.bar \5# RUN:    --rename-section=.tst2.foo=.tst2.ren.foo \6# RUN:    --rename-section=.tst3.foo=.tst3.ren.foo \7# RUN:    --rename-section=.tst4.foo=.tst4.ren.foo \8# RUN:    --rename-section=.rel.tst4.foo=.tst4.ren.foo.rel \9# RUN:    --rename-section=.tst6.got.plt=.tst6.ren.got.plt \10# RUN:    --rename-section=.tst7.rela.plt=.tst7.ren.rela.plt11# RUN: llvm-readobj --sections %t1 | FileCheck %s12 13!ELF14FileHeader:15  Class:   ELFCLASS6416  Data:    ELFDATA2LSB17  Type:    ET_REL18  Machine: EM_X86_6419Sections:20 21## Test 1. When a section is renamed, its relocation section should be renamed22## similarly.23# CHECK: Name: .tst1.ren.foo{{ }}24# CHECK: Name: .rel.tst1.ren.foo{{ }}25# CHECK: Name: .rela.tst1.ren.bar{{ }}26# CHECK: Name: .tst1.ren.bar{{ }}27  - Name:  .tst1.foo28    Type:  SHT_PROGBITS29  - Name:  .rel.tst1.foo30    Type:  SHT_REL31    Info:  .tst1.foo32  - Name:  .rela.tst1.bar33    Type:  SHT_RELA34    Info:  .tst1.bar35  - Name:  .tst1.bar36    Type:  SHT_PROGBITS37 38## Test 2. A relocation section should be renamed together with its target39## section even if its name does not follow the typical pattern.40# CHECK: Name: .tst2.ren.foo{{ }}41# CHECK: Name: .rel.tst2.ren.foo{{ }}42  - Name:  .tst2.foo43    Type:  SHT_PROGBITS44  - Name:  .tst2.foo.rel45    Type:  SHT_REL46    Info:  .tst2.foo47 48## Test 3. A relocation section should not be renamed if an unrelated section49## with the same common name is renamed.50## Note that '.rel.tst3.foo' targets '.tst3.bar', not '.tst3.foo'51# CHECK: Name: .tst3.ren.foo{{ }}52# CHECK: Name: .tst3.bar{{ }}53# CHECK: Name: .rel.tst3.foo{{ }}54  - Name:  .tst3.foo55    Type:  SHT_PROGBITS56  - Name:  .tst3.bar57    Type:  SHT_PROGBITS58  - Name:  .rel.tst3.foo59    Type:  SHT_REL60    Info:  .tst3.bar61 62## Test 4. A relocation section can be renamed with an explicit --rename-section63## command. Explicit renaming overrides implicit one.64# CHECK: Name: .tst4.ren.foo{{ }}65# CHECK: Name: .tst4.ren.foo.rel{{ }}66  - Name:  .tst4.foo67    Type:  SHT_PROGBITS68  - Name:  .rel.tst4.foo69    Type:  SHT_REL70    Info:  .tst4.foo71 72## Test 5. Should not rename a relocation section if it or its target are not73## specified in --rename-section.74## Note that this diverges from GNU objcopy.75# CHECK: Name: .tst5.foo{{ }}76# CHECK: Name: .tst5.foo.rel{{ }}77  - Name:  .tst5.foo78    Type:  SHT_PROGBITS79  - Name:  .tst5.foo.rel80    Type:  SHT_REL81    Info:  .tst5.foo82 83## Test 6. A dynamic relocation section should not be renamed together with its84## target section.85# CHECK: Name: .tst6.rela.plt{{ }}86# CHECK: Name: .tst6.ren.got.plt{{ }}87  - Name:  .tst6.rela.plt88    Type:  SHT_RELA89    Flags: [ SHF_ALLOC ]90    Info:  .tst6.got.plt91  - Name:  .tst6.got.plt92    Type:  SHT_PROGBITS93 94## Test 7. A dynamic relocation section can be renamed with an explicit95## --rename-section command.96# CHECK: Name: .tst7.ren.rela.plt{{ }}97# CHECK: Name: .tst7.got.plt{{ }}98  - Name:  .tst7.rela.plt99    Type:  SHT_RELA100    Flags: [ SHF_ALLOC ]101    Info:  .tst7.got.plt102  - Name:  .tst7.got.plt103    Type:  SHT_PROGBITS104