-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BOLT][RISCV] Handle CIE's produced by GNU as #69578
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
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,109 @@ | ||
## Compiled and stripped-down version of: | ||
## (riscv64-linux-gnu-gcc -nostdlib -static -Wl,-q cie-gnu.s) | ||
# .text | ||
# .globl _start | ||
# .type _start, @function | ||
# _start: | ||
# .cfi_startproc | ||
# beq a0, a1, 1f | ||
# ret | ||
# 1: | ||
# .cfi_undefined t0 # Arbitrary cfi command to force a new state | ||
# ret | ||
# .cfi_endproc | ||
# .size _start, .-_start | ||
|
||
--- !ELF | ||
FileHeader: | ||
Class: ELFCLASS64 | ||
Data: ELFDATA2LSB | ||
Type: ET_EXEC | ||
Machine: EM_RISCV | ||
Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_DOUBLE ] | ||
Entry: 0x10144 | ||
ProgramHeaders: | ||
- Type: PT_LOAD | ||
Flags: [ PF_X, PF_R ] | ||
FirstSec: .text | ||
LastSec: .eh_frame | ||
VAddr: 0x10000 | ||
Align: 0x1000 | ||
Offset: 0x0 | ||
Sections: | ||
- Name: .text | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] | ||
Address: 0x10144 | ||
AddressAlign: 0x2 | ||
Offset: 0x144 | ||
Content: 6303B50082808280 | ||
- Name: .eh_frame | ||
Type: SHT_PROGBITS | ||
Flags: [ SHF_ALLOC ] | ||
Address: 0x10150 | ||
AddressAlign: 0x8 | ||
Content: 1000000000000000037A5200017C01011B0D02001000000018000000D8FFFFFF0800000000460705 | ||
- Name: .rela.text | ||
Type: SHT_RELA | ||
Flags: [ SHF_INFO_LINK ] | ||
Link: .symtab | ||
AddressAlign: 0x8 | ||
Info: .text | ||
Relocations: | ||
- Offset: 0x10144 | ||
Symbol: ".L1\x021" | ||
Type: R_RISCV_BRANCH | ||
- Name: .rela.eh_frame | ||
Type: SHT_RELA | ||
Flags: [ SHF_INFO_LINK ] | ||
Link: .symtab | ||
AddressAlign: 0x8 | ||
Info: .eh_frame | ||
Relocations: | ||
- Offset: 0x1016C | ||
Symbol: '.L0 ' | ||
Type: R_RISCV_32_PCREL | ||
- Offset: 0x10170 | ||
Symbol: '.L0 (1)' | ||
Type: R_RISCV_ADD32 | ||
- Offset: 0x10170 | ||
Symbol: '.L0 ' | ||
Type: R_RISCV_SUB32 | ||
- Offset: 0x10175 | ||
Symbol: '.L0 (2)' | ||
Type: R_RISCV_SET6 | ||
- Offset: 0x10175 | ||
Symbol: '.L0 ' | ||
Type: R_RISCV_SUB6 | ||
- Type: SectionHeaderTable | ||
Sections: | ||
- Name: .text | ||
- Name: .rela.text | ||
- Name: .eh_frame | ||
- Name: .rela.eh_frame | ||
- Name: .symtab | ||
- Name: .strtab | ||
- Name: .shstrtab | ||
Symbols: | ||
- Name: '$x' | ||
Section: .text | ||
Value: 0x10144 | ||
- Name: ".L1\x021" | ||
Section: .text | ||
Value: 0x1014A | ||
- Name: '.L0 ' | ||
Section: .text | ||
Value: 0x10144 | ||
- Name: '.L0 (1)' | ||
Section: .text | ||
Value: 0x1014C | ||
- Name: '.L0 (2)' | ||
Section: .text | ||
Value: 0x1014A | ||
- Name: _start | ||
Type: STT_FUNC | ||
Section: .text | ||
Binding: STB_GLOBAL | ||
Value: 0x10144 | ||
Size: 0x8 | ||
... |
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,17 @@ | ||
# Test that BOLT can handle CIE's produced by GNU as. On RISC-V, GNU as produces | ||
# the following initial instruction: | ||
# DW_CFA_def_cfa_register: r2 | ||
# While I believe it is technically incorrect to use this instruction without | ||
# first using a DW_CFA_def_cfa (since the offset is unspecified), both readelf | ||
# and llvm-dwarfdump accept this and implicitly set the offset to 0. | ||
# In BOLT, this used to trigger an assert, however, since it (correctly) | ||
# believed the offset was not set. This test checks we can handle this | ||
# situation. | ||
|
||
RUN: yaml2obj -o %t %p/Inputs/cie-gnu.yaml | ||
RUN: llvm-bolt -o %t.bolt %t --reorder-blocks=reverse | ||
RUN: llvm-dwarfdump --debug-frame %t.bolt | FileCheck %s | ||
|
||
CHECK: 0x400000: CFA=X2 | ||
CHECK: 0x400004: CFA=X2: X5=undefined | ||
CHECK: 0x400006: CFA=X2 |
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.