// Copyright (c) 2026 Petr Balvín (https://petrbalvin.org) // SPDX-License-Identifier: BSD-3-Clause #include "textflag.h" // The link-regression kernel for arm64, the amd64 one's sibling: stack // discipline (add), an intra-file branch with link (probe calling seven, // R_CALLARM64), an ADRP+ADD pair against static data (word<>, // R_ADDRARM64), a symbol-valued DATA field (entry holding seven's // address, R_ADDR), NOPTR data outside the GC's type scan (counter) and // the data section itself. The callee's result slot sits at the caller's // SP+8, the arm64 ABI0 frame convention. // func add(a, b int64) int64 TEXT ·add(SB), NOSPLIT, $0-24 MOVD a+0(FP), R0 MOVD b+8(FP), R1 ADD R1, R0, R0 MOVD R0, ret+16(FP) RET // func seven() int64 TEXT ·seven(SB), NOSPLIT, $0-8 MOVD $7, R0 MOVD R0, ret+0(FP) RET // func probe() int64 = seven() + word<>(SB) TEXT ·probe(SB), NOSPLIT, $8-8 BL ·seven(SB) MOVD 8(RSP), R0 MOVD $word<>(SB), R4 MOVD (R4), R5 ADD R5, R0, R0 MOVD R0, ret+0(FP) RET // func entryAddr() uintptr TEXT ·entryAddr(SB), NOSPLIT, $0-8 MOVD entry(SB), R4 MOVD R4, ret+0(FP) RET // func counterVal() int64 TEXT ·counterVal(SB), NOSPLIT, $0-8 MOVD counter(SB), R4 MOVD R4, ret+0(FP) RET GLOBL word<>(SB), RODATA, $8 DATA word<>+0(SB)/8, $0x0fedcba987654321 GLOBL entry(SB), RODATA, $8 DATA entry+0(SB)/8, $·seven(SB) GLOBL counter(SB), NOPTR, $8 DATA counter+0(SB)/8, $1234