-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm-objcopy] Add --prefix-alloc-sections
This patch adds support for --prefix-alloc-sections, which adds a prefix to every allocated section names. It adds a prefix after renaming section names by --rename-section as GNU objcopy does. Fixes PR41266: https://bugs.llvm.org/show_bug.cgi?id=41266 Differential Revision: https://reviews.llvm.org/D60042 Patch by Seiya Nuta. llvm-svn: 360233
- Loading branch information
Showing
8 changed files
with
146 additions
and
10 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
llvm/test/tools/llvm-objcopy/ELF/prefix-alloc-sections-dynrelocsec.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# RUN: llvm-objcopy --prefix-alloc-sections=.prefix %p/Inputs/dynrel.elf %t | ||
# RUN: llvm-readobj --sections %t | FileCheck %s | ||
|
||
# CHECK: Name: .prefix.rela.plt | ||
# CHECK: Name: .prefix.plt |
36 changes: 36 additions & 0 deletions
36
llvm/test/tools/llvm-objcopy/ELF/prefix-alloc-sections.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# RUN: yaml2obj %s > %t | ||
# RUN: llvm-objcopy --prefix-alloc-sections=.prefix %t %t2 | ||
# RUN: llvm-readobj --sections %t2 | FileCheck %s | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .foo | ||
Type: SHT_PROGBITS | ||
Flags: [ ] | ||
- Name: .prefix.already_prefixed | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
- Name: .rel.text | ||
Type: SHT_REL | ||
Info: .text | ||
- Name: .rela.data | ||
Type: SHT_RELA | ||
Info: .data | ||
- Name: .data | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
|
||
# CHECK: Name: .foo | ||
# CHECK: Name: .prefix.prefix.already_prefixed | ||
# CHECK: Name: .prefix.text | ||
# CHECK: Name: .rel.prefix.text | ||
# CHECK: Name: .rela.prefix.data | ||
# CHECK: Name: .prefix.data |
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/llvm-objcopy/ELF/rename-section-and-prefix-alloc-sections.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# RUN: yaml2obj %s > %t | ||
# RUN: llvm-objcopy --rename-section=.text=.text2 --rename-section=.data=.data2 --prefix-alloc-sections=.prefix %t %t2 | ||
# RUN: llvm-readobj --sections %t2 | FileCheck %s | ||
|
||
# .text/.rel.text and .data/.rela.data are the cases when the relocation section | ||
# comes after/before its target section respectively. We handle them in different | ||
# ways to perform both --rename-section and --prefix-alloc-sections in one pass. | ||
|
||
!ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_REL | ||
Machine: EM_X86_64 | ||
Sections: | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
- Name: .rel.text | ||
Type: SHT_REL | ||
Info: .text | ||
- Name: .rela.data | ||
Type: SHT_RELA | ||
Info: .data | ||
- Name: .data | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
|
||
# CHECK: Name: .prefix.text2 | ||
# CHECK: Name: .rel.prefix.text2 | ||
# CHECK: Name: .rela.prefix.data2 | ||
# CHECK: Name: .prefix.data2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters