From 7cab55dfd38ca24c327a648907d6befbf828447e Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Mon, 4 Nov 2019 02:31:37 +1100 Subject: 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 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- src/cmd/asm/internal/asm/testdata/riscvenc.s | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/cmd/asm') 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 -- cgit v1.3