forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BOLT] Adjust section sizes based on file offsets (llvm#80226)
When we adjust section sizes while rewriting a binary, we should be using section offsets and not addresses to determine if section overlap. NFC for existing binaries.
- Loading branch information
Showing
2 changed files
with
67 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
## Check that llvm-bolt correctly processes a binary with program headers and | ||
## corresponding sections specified in non-ascending address order. | ||
|
||
RUN: split-file %s %t | ||
RUN: yaml2obj %t/yaml -o %t.exe --max-size=0 | ||
RUN: llvm-bolt %t.exe -o %t.bolt --allow-stripped | ||
RUN: llvm-readelf -WS %t.bolt | FileCheck %s | ||
|
||
CHECK: .a PROGBITS 0000000000400000 [[#%.6x, OFFSET:]] 000001 | ||
CHECK-NEXT: .b PROGBITS 0000000000000000 [[#%.6x, OFFSET+1]] 000001 | ||
CHECK-NEXT: .c PROGBITS 0000000000600000 [[#%.6x, OFFSET+2]] 000001 | ||
|
||
#--- yaml | ||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_EXEC | ||
Machine: EM_X86_64 | ||
ProgramHeaders: | ||
- Type: PT_LOAD | ||
FirstSec: .a | ||
LastSec: .a | ||
VAddr: 0x400000 | ||
- Type: PT_LOAD | ||
FirstSec: .b | ||
LastSec: .b | ||
VAddr: 0x0 | ||
- Type: PT_LOAD | ||
FirstSec: .c | ||
LastSec: .c | ||
VAddr: 0x600000 | ||
Sections: | ||
- Name: .a | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
Content: 00 | ||
AddressAlign: 0x1 | ||
Address: 0x400000 | ||
- Name: .b | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
Content: 00 | ||
AddressAlign: 0x1 | ||
Address: 0x0 | ||
- Name: .c | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
Content: 00 | ||
AddressAlign: 0x1 | ||
Address: 0x600000 | ||
... |