feat(asm): encode indirect JMP and CALL on all four architectures
Assisted-by: GLM 5.3 Flash
This commit is contained in:
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Indirect control flow: JMP/CALL through a register or memory, byte-compared
|
||||
// against go tool asm. A CALL in the body also exercises the toolchain's
|
||||
// forced base-pointer frame on a frameless function.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func f()
|
||||
TEXT ·f(SB), NOSPLIT, $0
|
||||
JMP AX
|
||||
CALL AX
|
||||
JMP (BX)
|
||||
CALL (BX)
|
||||
JMP 8(BX)
|
||||
JMP R8
|
||||
RET
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Indirect control flow: JMP (R0) and CALL (R0) lower to BR/BLR, the only
|
||||
// indirect-branch spellings the toolchain accepts (the raw BR/BLR mnemonics
|
||||
// stay a gasm superset).
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func f()
|
||||
TEXT ·f(SB), NOSPLIT, $0
|
||||
JMP (R0)
|
||||
CALL (R0)
|
||||
RET
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Indirect control flow: JMP (R4) and JAL (R5) are the toolchain's spellings
|
||||
// for jirl; the raw JIRL instruction is deliberately absent, because the Go
|
||||
// loong64 assembler deletes it and a parity kernel could not hold it.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func f()
|
||||
TEXT ·f(SB), NOSPLIT, $0-0
|
||||
JMP (R4)
|
||||
JAL (R5)
|
||||
RET
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Indirect control flow: JMP (X5) lowers to JALR X0, 0(X5), the trampoline
|
||||
// form JALR rd, offset(rs1) encodes with the destination first, and a linking
|
||||
// JALR through X1 is the toolchain's only indirect call.
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func f()
|
||||
TEXT ·leaf(SB), NOSPLIT, $0-0
|
||||
JMP (X5)
|
||||
JALR X0, 0(X6)
|
||||
RET
|
||||
|
||||
// func g()
|
||||
TEXT ·calls(SB), NOSPLIT, $0-0
|
||||
JALR X1, 0(X8)
|
||||
RET
|
||||
Reference in New Issue
Block a user