forked from openhwgroup/corev-binutils-gdb
-
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.
GAS tries to relax a conditional branch by flipping the condition bit and setting the offset to a two-instruction-length constant. relax bne t5,t3,.Lfar_away to beq t5,t3,8 # a constant value j .Lfar_away To solve this issue, we add a local symbol right after the `j` instruction, and then the linker can help adjust bytes during linker relaxation.
- Loading branch information
1 parent
02ec8cd
commit c549628
Showing
4 changed files
with
93 additions
and
2 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,19 @@ | ||
#as: -march=rv32g_zca_zcmt | ||
#source: zc-zcmt-relax-branch.s | ||
#objdump: -dr -Mno-aliases | ||
|
||
.*:[ ]+file format .* | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
0+000 <target>: | ||
[ ]*[0-9a-f]+:[ ]+00940263[ ]+beq[ ]+s0,s1,4.+ | ||
[^:]+: R_RISCV_BRANCH[ ]+NORMAL | ||
|
||
0+4 <NORMAL>: | ||
[ ]*[0-9a-f]+:[ ]+00941463[ ]+bne[ ]+s0,s1,c.+ | ||
[^:]+: R_RISCV_BRANCH[ ]+\.L0 | ||
[ ]*[0-9a-f]+:[ ]+0000006f[ ]+jal[ ]+zero,8.+ | ||
[^:]+: R_RISCV_JAL[ ]+\*ABS\*\-0x4 | ||
[ ]*[0-9a-f]+:[ ]+8082[ ]+c.jr[ ]+ra |
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,6 @@ | ||
.option norelax | ||
target: | ||
beq s0,s1,NORMAL | ||
NORMAL: | ||
beq s0,s1,-4 | ||
ret |
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,31 @@ | ||
#as: -march=rv32g_zca_zcmt | ||
#source: zc-zcmt-relax-c-branch.s | ||
#objdump: -dr -Mno-aliases | ||
|
||
.*:[ ]+file format .* | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
0+000 <target>: | ||
[ ]*[0-9a-f]+:[ ]+c009[ ]+c.beqz[ ]+s0,2.+ | ||
[^:]+: R_RISCV_RVC_BRANCH[ ]+C_BRANCH_RANGE | ||
|
||
0+2 <C_BRANCH_RANGE>: | ||
[ ]*[0-9a-f]+:[ ]+10041263[ ]+bne[ ]+s0,zero,106.+ | ||
[^:]+: R_RISCV_BRANCH[ ]+EXPAND_TO_BRANCH | ||
#... | ||
|
||
.+ <EXPAND_TO_BRANCH>: | ||
[ ]*[0-9a-f]+:[ ]+c019[ ]+c.beqz[ ]+s0,10c.+ | ||
[^:]+: R_RISCV_RVC_BRANCH[ ]+\.L0 | ||
[ ]*[0-9a-f]+:[ ]+0040106f[ ]+jal[ ]+zero,110c.+ | ||
[^:]+: R_RISCV_JAL[ ]+FLIP_C_BRANCH_AND_JUMP | ||
#... | ||
|
||
.+ <FLIP_C_BRANCH_AND_JUMP>: | ||
[ ]*[0-9a-f]+:[ ]+00041463[ ]+bne[ ]+s0,zero,1114.+ | ||
[^:]+: R_RISCV_BRANCH[ ]+\.L0 | ||
[ ]*[0-9a-f]+:[ ]+0000006f[ ]+jal[ ]+zero,1110.+ | ||
[^:]+: R_RISCV_JAL[ ]+\*ABS\*\-0x4 | ||
[ ]*[0-9a-f]+:[ ]+8082[ ]+c.jr[ ]+ra |