| 1 |
# RUN: yaml2obj %s -o %t |
| 2 |
# 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.plt |
| 11 |
# RUN: llvm-readobj --sections %t1 | FileCheck %s |
| 12 |
|
| 13 |
!ELF |
| 14 |
FileHeader: |
| 15 |
Class: ELFCLASS64 |
| 16 |
Data: ELFDATA2LSB |
| 17 |
Type: ET_REL |
| 18 |
Machine: EM_X86_64 |
| 19 |
Sections: |
| 20 |
|
| 21 |
## Test 1. When a section is renamed, its relocation section should be renamed |
| 22 |
## 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.foo |
| 28 |
Type: SHT_PROGBITS |
| 29 |
- Name: .rel.tst1.foo |
| 30 |
Type: SHT_REL |
| 31 |
Info: .tst1.foo |
| 32 |
- Name: .rela.tst1.bar |
| 33 |
Type: SHT_RELA |
| 34 |
Info: .tst1.bar |
| 35 |
- Name: .tst1.bar |
| 36 |
Type: SHT_PROGBITS |
| 37 |
|
| 38 |
## Test 2. A relocation section should be renamed together with its target |
| 39 |
## 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.foo |
| 43 |
Type: SHT_PROGBITS |
| 44 |
- Name: .tst2.foo.rel |
| 45 |
Type: SHT_REL |
| 46 |
Info: .tst2.foo |
| 47 |
|
| 48 |
## Test 3. A relocation section should not be renamed if an unrelated section |
| 49 |
## 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.foo |
| 55 |
Type: SHT_PROGBITS |
| 56 |
- Name: .tst3.bar |
| 57 |
Type: SHT_PROGBITS |
| 58 |
- Name: .rel.tst3.foo |
| 59 |
Type: SHT_REL |
| 60 |
Info: .tst3.bar |
| 61 |
|
| 62 |
## Test 4. A relocation section can be renamed with an explicit --rename-section |
| 63 |
## command. Explicit renaming overrides implicit one. |
| 64 |
# CHECK: Name: .tst4.ren.foo{{ }} |
| 65 |
# CHECK: Name: .tst4.ren.foo.rel{{ }} |
| 66 |
- Name: .tst4.foo |
| 67 |
Type: SHT_PROGBITS |
| 68 |
- Name: .rel.tst4.foo |
| 69 |
Type: SHT_REL |
| 70 |
Info: .tst4.foo |
| 71 |
|
| 72 |
## Test 5. Should not rename a relocation section if it or its target are not |
| 73 |
## 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.foo |
| 78 |
Type: SHT_PROGBITS |
| 79 |
- Name: .tst5.foo.rel |
| 80 |
Type: SHT_REL |
| 81 |
Info: .tst5.foo |
| 82 |
|
| 83 |
## Test 6. A dynamic relocation section should not be renamed together with its |
| 84 |
## target section. |
| 85 |
# CHECK: Name: .tst6.rela.plt{{ }} |
| 86 |
# CHECK: Name: .tst6.ren.got.plt{{ }} |
| 87 |
- Name: .tst6.rela.plt |
| 88 |
Type: SHT_RELA |
| 89 |
Flags: [ SHF_ALLOC ] |
| 90 |
Info: .tst6.got.plt |
| 91 |
- Name: .tst6.got.plt |
| 92 |
Type: SHT_PROGBITS |
| 93 |
|
| 94 |
## Test 7. A dynamic relocation section can be renamed with an explicit |
| 95 |
## --rename-section command. |
| 96 |
# CHECK: Name: .tst7.ren.rela.plt{{ }} |
| 97 |
# CHECK: Name: .tst7.got.plt{{ }} |
| 98 |
- Name: .tst7.rela.plt |
| 99 |
Type: SHT_RELA |
| 100 |
Flags: [ SHF_ALLOC ] |
| 101 |
Info: .tst7.got.plt |
| 102 |
- Name: .tst7.got.plt |
| 103 |
Type: SHT_PROGBITS |