aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorTsukasa OI <research_trasio@irq.a4lg.com>2022-08-27 00:11:01 +0000
committerNelson Chu <nelson@rivosinc.com>2022-09-02 14:03:28 +0800
commit8fe1be5fabd097a8b9110ab63729e08c0d686660 (patch)
treeff5688584010bebd58ea37cfdc8900eafb40b85d /gas
parent48525554d5222d98953202b9252ff65fdead58a4 (diff)
downloadfsf-binutils-gdb-8fe1be5fabd097a8b9110ab63729e08c0d686660.zip
fsf-binutils-gdb-8fe1be5fabd097a8b9110ab63729e08c0d686660.tar.gz
fsf-binutils-gdb-8fe1be5fabd097a8b9110ab63729e08c0d686660.tar.bz2
RISC-V: Print highest address (-1) on the disassembler
This patch makes possible to print the highest address (-1) and the addresses related to gp which value is -1. This is particularly useful if the highest address space is used for I/O registers and corresponding symbols are defined. Besides, 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. gas/ChangeLog: * testsuite/gas/riscv/dis-addr-topaddr.s: New test for the top address (-1) printing. * testsuite/gas/riscv/dis-addr-topaddr-32.d: Likewise. * testsuite/gas/riscv/dis-addr-topaddr-64.d: Likewise. * testsuite/gas/riscv/dis-addr-topaddr-gp.s: New test for GP-relative addressing when GP is the highest address (-1). * testsuite/gas/riscv/dis-addr-topaddr-gp-32.d: Likewise. * testsuite/gas/riscv/dis-addr-topaddr-gp-64.d: Likewise. opcodes/ChangeLog: * riscv-dis.c (struct riscv_private_data): Add `to_print_addr' to enable printing the highest address. (maybe_print_address): Utilize `to_print_addr'. (riscv_disassemble_insn): Likewise.
Diffstat (limited to 'gas')
-rw-r--r--gas/testsuite/gas/riscv/dis-addr-topaddr-32.d11
-rw-r--r--gas/testsuite/gas/riscv/dis-addr-topaddr-64.d11
-rw-r--r--gas/testsuite/gas/riscv/dis-addr-topaddr-gp-32.d12
-rw-r--r--gas/testsuite/gas/riscv/dis-addr-topaddr-gp-64.d12
-rw-r--r--gas/testsuite/gas/riscv/dis-addr-topaddr-gp.s15
-rw-r--r--gas/testsuite/gas/riscv/dis-addr-topaddr.s10
6 files changed, 71 insertions, 0 deletions
diff --git a/gas/testsuite/gas/riscv/dis-addr-topaddr-32.d b/gas/testsuite/gas/riscv/dis-addr-topaddr-32.d
new file mode 100644
index 0000000..87854cd
--- /dev/null
+++ b/gas/testsuite/gas/riscv/dis-addr-topaddr-32.d
@@ -0,0 +1,11 @@
+#as: -march=rv32ic
+#source: dis-addr-topaddr.s
+#objdump: -d
+
+.*: file format elf32-(little|big)riscv
+
+
+Disassembly of section .text:
+
+0+000 <target>:
+[ ]+[0-9a-f]+:[ ]+fff00283[ ]+lb[ ]+t0,-1\(zero\) # ffffffff <addr_top>
diff --git a/gas/testsuite/gas/riscv/dis-addr-topaddr-64.d b/gas/testsuite/gas/riscv/dis-addr-topaddr-64.d
new file mode 100644
index 0000000..38f67ef
--- /dev/null
+++ b/gas/testsuite/gas/riscv/dis-addr-topaddr-64.d
@@ -0,0 +1,11 @@
+#as: -march=rv64ic -defsym rv64=1
+#source: dis-addr-topaddr.s
+#objdump: -d
+
+.*: file format elf64-(little|big)riscv
+
+
+Disassembly of section .text:
+
+0+000 <target>:
+[ ]+[0-9a-f]+:[ ]+fff00283[ ]+lb[ ]+t0,-1\(zero\) # ffffffffffffffff <addr_top>
diff --git a/gas/testsuite/gas/riscv/dis-addr-topaddr-gp-32.d b/gas/testsuite/gas/riscv/dis-addr-topaddr-gp-32.d
new file mode 100644
index 0000000..875bfe7
--- /dev/null
+++ b/gas/testsuite/gas/riscv/dis-addr-topaddr-gp-32.d
@@ -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>
diff --git a/gas/testsuite/gas/riscv/dis-addr-topaddr-gp-64.d b/gas/testsuite/gas/riscv/dis-addr-topaddr-gp-64.d
new file mode 100644
index 0000000..5ac4b52
--- /dev/null
+++ b/gas/testsuite/gas/riscv/dis-addr-topaddr-gp-64.d
@@ -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>
diff --git a/gas/testsuite/gas/riscv/dis-addr-topaddr-gp.s b/gas/testsuite/gas/riscv/dis-addr-topaddr-gp.s
new file mode 100644
index 0000000..6ba9fc7
--- /dev/null
+++ b/gas/testsuite/gas/riscv/dis-addr-topaddr-gp.s
@@ -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)
diff --git a/gas/testsuite/gas/riscv/dis-addr-topaddr.s b/gas/testsuite/gas/riscv/dis-addr-topaddr.s
new file mode 100644
index 0000000..b66587f
--- /dev/null
+++ b/gas/testsuite/gas/riscv/dis-addr-topaddr.s
@@ -0,0 +1,10 @@
+.ifdef rv64
+topbase = 0xffffffff00000000
+.else
+topbase = 0
+.endif
+
+.set addr_top, topbase + 0xffffffff # -1
+
+target:
+ lb t0, -1(zero)