2026-09-19 19:17:07 +02:00
|
|
|
// 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
|
2026-09-19 23:49:27 +02:00
|
|
|
JMP (X5)
|
2026-09-19 19:17:07 +02:00
|
|
|
JALR X0, 0(X6)
|
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
|
// func g()
|
|
|
|
|
TEXT ·calls(SB), NOSPLIT, $0-0
|
|
|
|
|
JALR X1, 0(X8)
|
|
|
|
|
RET
|