aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2019-11-04 02:31:37 +1100
committerJoel Sing <joel@sing.id.au>2019-12-24 03:42:15 +0000
commit7cab55dfd38ca24c327a648907d6befbf828447e (patch)
treefc68d31e9a949eac9bb764529a35335a42c7a3a0 /src/cmd/asm
parent372efbbf3170ccf260186118cd3acf7f617055ae (diff)
downloadgo-7cab55dfd38ca24c327a648907d6befbf828447e.tar.xz
cmd/internal/obj/riscv: handle call, jmp and branch
Also provide REG_LR to more clearly define the link register. Based on the riscv-go port. Updates #27532 Change-Id: I0805f373682f93b3918a01c21d4ef34eb3817c75 Reviewed-on: https://go-review.googlesource.com/c/go/+/204627 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/asm')
-rw-r--r--src/cmd/asm/internal/asm/testdata/riscvenc.s15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/asm/internal/asm/testdata/riscvenc.s b/src/cmd/asm/internal/asm/testdata/riscvenc.s
index 73f41dd877..21d1c40d9d 100644
--- a/src/cmd/asm/internal/asm/testdata/riscvenc.s
+++ b/src/cmd/asm/internal/asm/testdata/riscvenc.s
@@ -267,3 +267,18 @@ start:
MOVD 4(X5), F0 // 07b04200
MOVD F0, 4(X5) // 27b20200
MOVD F0, F1 // d3000022
+
+ // These jumps can get printed as jumps to 2 because they go to the
+ // second instruction in the function (the first instruction is an
+ // invisible stack pointer adjustment).
+ JMP start // JMP 2 // 6ff05fcd
+ JMP (X5) // 67800200
+ JMP 4(X5) // 67804200
+
+ // JMP and CALL to symbol are encoded as:
+ // AUIPC $0, TMP
+ // JALR $0, TMP
+ // with a R_RISCV_PCREL_ITYPE relocation - the linker resolves the
+ // real address and updates the immediates for both instructions.
+ CALL asmtest(SB) // 970f0000
+ JMP asmtest(SB) // 970f0000