-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[BOLT] Add --custom-allocation-vma flag #136385
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Check that we are able to rewrite binaries when we fail to identify a | ||
// suitable location to put new code and user supplies a custom one via | ||
// --custom-allocation-vma. This happens more obviously if the binary has | ||
// segments mapped to very high addresses. | ||
|
||
// In this example, my.reserved.section is mapped to a segment to be loaded | ||
// at address 0x10000000000, while regular text should be at 0x200000. We | ||
// pick a vma in the middle at 0x700000 to carve space for BOLT to put data, | ||
// since BOLT's usual route of allocating after the last segment will put | ||
// code far away and that will blow up relocations from main. | ||
|
||
// RUN: split-file %s %t | ||
// RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o | ||
// RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-T %t/main.ls | ||
// RUN: llvm-bolt %t.exe -o %t.bolt --custom-allocation-vma=0x700000 | ||
|
||
//--- main.s | ||
.type reserved_space,@object | ||
.section .my.reserved.section,"awx",@nobits | ||
.globl reserved_space | ||
.p2align 4, 0x0 | ||
reserved_space: | ||
.zero 0x80000000 | ||
.size reserved_space, 0x80000000 | ||
|
||
.text | ||
.globl main | ||
.globl _start | ||
.type main, %function | ||
_start: | ||
main: | ||
.cfi_startproc | ||
nop | ||
nop | ||
nop | ||
retq | ||
.cfi_endproc | ||
.size main, .-main | ||
|
||
//--- main.ls | ||
SECTIONS | ||
{ | ||
.my.reserved.section 1<<40 : { | ||
*(.my.reserved.section); | ||
} | ||
} INSERT BEFORE .comment; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want this flag to be at the top level or hidden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's a good idea to put it hidden. Let me do that.