-
Notifications
You must be signed in to change notification settings - Fork 13.6k
ELF: Introduce --randomize-section-padding option. #117653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
75ad826
[𝘀𝗽𝗿] initial version
pcc c420199
format
pcc 667e7ba
Add tests
pcc 678959e
Address review comments
pcc a02fa37
Add linker script test
pcc cd48297
Address review comments
pcc bdbf795
Add new output sections to man page
pcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,88 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o | ||
|
||
## --randomize-section-padding= inserts segment offset padding and pre-section | ||
## padding, and does not affect flags. Segment offset padding is only inserted | ||
## when PT_LOAD changes, as shown by .bss size (.data and .bss share a PT_LOAD). | ||
|
||
# RUN: ld.lld --randomize-section-padding=6 %t.o -o %t.out | ||
# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t.out | FileCheck --check-prefix=PAD6 %s | ||
|
||
# PAD6: .rodata PROGBITS 0000000000200158 000158 000b8d 00 A 0 0 1 | ||
# PAD6: .text PROGBITS 0000000000201ce8 000ce8 000270 00 AX 0 0 4 | ||
# PAD6: .data PROGBITS 0000000000202f58 000f58 000941 00 WA 0 0 1 | ||
# PAD6: .bss NOBITS 0000000000203899 001899 000003 00 WA 0 0 1 | ||
|
||
# PAD6: 0000000000203899 0 NOTYPE LOCAL DEFAULT 4 a | ||
# PAD6: 000000000020389a 0 NOTYPE LOCAL DEFAULT 4 b | ||
# PAD6: 000000000020389b 0 NOTYPE LOCAL DEFAULT 4 c | ||
|
||
# PAD6: Hex dump of section '.rodata': | ||
# PAD6: 0x00200cd8 00000000 00000000 00000102 03 | ||
# PAD6: Hex dump of section '.text': | ||
# PAD6: 0x00201f48 cccccccc cccccccc cccccccc 0405cc06 | ||
# PAD6: Hex dump of section '.data': | ||
# PAD6: 0x00203888 00000000 00000000 00000000 00000708 | ||
# PAD6: 0x00203898 09 | ||
|
||
## Size of segment offset padding and location of pre-section padding is | ||
## dependent on the seed. | ||
|
||
# RUN: ld.lld --randomize-section-padding=46 %t.o -o %t.out | ||
# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t.out | FileCheck --check-prefix=PAD46 %s | ||
|
||
# PAD46: .rodata PROGBITS 0000000000200158 000158 000cc0 00 A 0 0 1 | ||
# PAD46: .text PROGBITS 0000000000201e18 000e18 0009bf 00 AX 0 0 4 | ||
# PAD46: .data PROGBITS 00000000002037d7 0017d7 000540 00 WA 0 0 1 | ||
# PAD46: .bss NOBITS 0000000000203d17 001d17 000004 00 WA 0 0 1 | ||
|
||
# PAD46: 0000000000203d17 0 NOTYPE LOCAL DEFAULT 4 a | ||
# PAD46: 0000000000203d18 0 NOTYPE LOCAL DEFAULT 4 b | ||
# PAD46: 0000000000203d1a 0 NOTYPE LOCAL DEFAULT 4 c | ||
|
||
# PAD46: Hex dump of section '.rodata': | ||
# PAD46: 0x00200e08 00000000 00000000 00000000 00010203 | ||
# PAD46: Hex dump of section '.text': | ||
# PAD46: 0x002027c8 cccccccc cccccccc cccccccc 040506 | ||
# PAD46: Hex dump of section '.data': | ||
# PAD46: 0x00203d07 00000000 00000000 00000000 07000809 | ||
|
||
.section .rodata.a,"a",@progbits | ||
.byte 1 | ||
|
||
.section .rodata.b,"a",@progbits | ||
.byte 2 | ||
|
||
.section .rodata.c,"a",@progbits | ||
.byte 3 | ||
|
||
.section .text.a,"ax",@progbits | ||
.byte 4 | ||
|
||
.section .text.b,"ax",@progbits | ||
.byte 5 | ||
|
||
.section .text.c,"ax",@progbits | ||
.byte 6 | ||
|
||
.section .data.a,"aw",@progbits | ||
.byte 7 | ||
|
||
.section .data.b,"aw",@progbits | ||
.byte 8 | ||
|
||
.section .data.c,"aw",@progbits | ||
.byte 9 | ||
|
||
.section .bss.a,"a",@nobits | ||
a: | ||
.zero 1 | ||
|
||
.section .bss.b,"a",@nobits | ||
b: | ||
.zero 1 | ||
|
||
.section .bss.c,"a",@nobits | ||
c: | ||
.zero 1 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.