-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Print top GP-relative addresses on the disassembler
This patch makes possible to print the address relative to the global pointer even if the corresponding symbol is the highest address (0xffffffff on RV32, 0xffffffff_ffffffff on RV64). Despite that it is very rare to have GP the highest address, it would be nice because we enabled highest address printing on regular cases. opcodes/ChangeLog: * riscv-dis.c (struct riscv_private_data): Add `has_gp' to enable printing the addresses relative to GP with the highest address. (maybe_print_address): Utilize `has_gp'. (riscv_disassemble_insn): Likewise. gas/ChangeLog: * testsuite/gas/riscv/dis-addr-topaddr-gp.s: New test for GP- relative addressing when GP is the highest address. * testsuite/gas/riscv/dis-addr-topaddr-gp-32.d: Likewise. * testsuite/gas/riscv/dis-addr-topaddr-gp-64.d: Likewise.
- Loading branch information
Showing
4 changed files
with
47 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#as: -march=rv32i | ||
#source: dis-addr-topaddr-gp.s | ||
#objdump: -d | ||
|
||
.*: file format elf32-(little|big)riscv | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
0+000 <target>: | ||
[ ]+[0-9a-f]+:[ ]+0051a283[ ]+lw[ ]+t0,5\(gp\) # 4 <addr_rel_gp_pos> | ||
[ ]+[0-9a-f]+:[ ]+ffd1a303[ ]+lw[ ]+t1,-3\(gp\) # fffffffc <addr_rel_gp_neg> |
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 @@ | ||
#as: -march=rv64i -defsym rv64=1 | ||
#source: dis-addr-topaddr-gp.s | ||
#objdump: -d | ||
|
||
.*: file format elf64-(little|big)riscv | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
0+000 <target>: | ||
[ ]+[0-9a-f]+:[ ]+0051a283[ ]+lw[ ]+t0,5\(gp\) # 4 <addr_rel_gp_pos> | ||
[ ]+[0-9a-f]+:[ ]+ffd1a303[ ]+lw[ ]+t1,-3\(gp\) # fffffffffffffffc <addr_rel_gp_neg> |
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,15 @@ | ||
.ifdef rv64 | ||
topbase = 0xffffffff00000000 | ||
.else | ||
topbase = 0 | ||
.endif | ||
|
||
.set __global_pointer$, topbase + 0xffffffff # -1 | ||
.set addr_rel_gp_pos, 0x00000004 # +4 | ||
.set addr_rel_gp_neg, topbase + 0xfffffffc # -4 | ||
|
||
target: | ||
# Use addresses relative to gp | ||
# (gp is the highest address) | ||
lw t0, +5(gp) | ||
lw t1, -3(gp) |
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