-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Refer mapping symbol to R_RISCV_RELAX for rvc relaxations.
RISC-V Psabi pr116, riscv-non-isa/riscv-elf-psabi-doc#116 bfd/ * elfnn-riscv.c (_bfd_riscv_enable_rvc): New function to check the mapping symbol with architecture string in the R_RISCV_RELAX, to see if rvc is enabled or not. If we don't find any mapping symbols, then just check the elf header flag as usual. (_bfd_riscv_relax_call): Updated since above change. (_bfd_riscv_relax_lui): Likewise. gas/ * config/tc-riscv.c (append_insn): Store $x+arch in tc_fix_data if exsit. (md_apply_fix): Refer the $x+arch from tc_fix_data into R_RISCV_RELAX, these only for the relocations used to do rvc relaxation. Besides, set addend of R_RISCV_RELAX (fx_offset) to zero. * config/tc-riscv.h (TC_FIX_TYPE): Defined to store $x+arch in each fixup only for risc-v target. (struct riscv_fixup_type): Likewise. (TC_INIT_FIX_DATA): Likewise. * testsuite/gas/riscv/mapping-relax.d: New testcase. * testsuite/gas/riscv/mapping-relax.s: Likewise. ld/ * testsuite/ld-riscv-elf/c-relax.d: New testcase for specific rvc relaxation. * testsuite/ld-riscv-elf/c-relax.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
- Loading branch information
1 parent
50f6417
commit 5491579
Showing
8 changed files
with
121 additions
and
5 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
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 | Di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-f]+[ ]+R_RISCV_RELAX[ ]+0 | ||
[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+[0-9a-f]+[ ]+foo \+ 0 | ||
[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_RELAX[ ]+[0-9a-f]+[ ]+\$xrv32i2p1_c2p0 \+ 0 |
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,21 @@ | ||
.attribute arch, "rv32i" | ||
.option relax | ||
foo: | ||
.align 2 | ||
lui a0, %hi (foo) | ||
addi a0, a0, %lo (foo + 4) | ||
.option arch, +a | ||
lui a0, %tprel_hi (i) | ||
add a0, a0, tp, %tprel_add (i) | ||
lw a1, %tprel_lo (i) (a0) | ||
.option arch, -a, +c | ||
L1: auipc a0, %pcrel_hi (foo) | ||
addi a0, a0, %pcrel_lo (L1) | ||
call foo | ||
|
||
.globl i | ||
.section .tbss, "awT", @nobits | ||
.type i, @object | ||
.size i, 4 | ||
i: | ||
.zero 4 |
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,16 @@ | ||
#source: c-relax.s | ||
#ld: --relax | ||
#objdump: -d -Mno-aliases | ||
|
||
.*:[ ]+file format .* | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
0+[0-9a-f]+ <_start>: | ||
.*:[ ]+[0-9a-f]+[ ]+lui[ ]+.* | ||
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+.* | ||
.*:[ ]+[0-9a-f]+[ ]+c\.lui[ ]+.* | ||
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+.* | ||
.*:[ ]+[0-9a-f]+[ ]+c\.j[ ]+.* | ||
.*:[ ]+[0-9a-f]+[ ]+jal[ ]+.* |
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,12 @@ | ||
.option relax | ||
.option arch, -c | ||
.globl _start | ||
_start: | ||
lui a0, %hi (_start) | ||
addi a0, a0, %lo (_start) | ||
.option arch, +c | ||
lui a0, %hi (_start) | ||
addi a0, a0, %lo (_start) | ||
call zero, _start | ||
.option arch, -c | ||
call zero, _start |
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