test(verify): gate GOOBJ link parity with cmd/link

Assisted-by: GLM 5.3
This commit is contained in:
2026-10-02 00:40:54 +02:00
parent 17cc49fee4
commit dd1782c538
6 changed files with 562 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
#include "textflag.h"
// The link-regression kernel for amd64. One file exercises every GOOBJ
// record a small assembly contribution to a program needs: plain stack
// discipline (add), an intra-file call (probe calling seven, R_CALL), a
// code-to-data reference (word<>, R_PCREL), 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.
// func add(a, b int64) int64
TEXT ·add(SB), NOSPLIT, $0-24
MOVQ a+0(FP), AX
MOVQ b+8(FP), CX
ADDQ CX, AX
MOVQ AX, ret+16(FP)
RET
// func seven() int64
TEXT ·seven(SB), NOSPLIT, $0-8
MOVQ $7, AX
MOVQ AX, ret+0(FP)
RET
// func probe() int64 = seven() + word<>(SB)
TEXT ·probe(SB), NOSPLIT, $8-8
CALL ·seven(SB)
MOVQ (SP), AX
MOVQ word<>(SB), CX
ADDQ CX, AX
MOVQ AX, ret+0(FP)
RET
// func entryAddr() uintptr
TEXT ·entryAddr(SB), NOSPLIT, $0-8
MOVQ entry(SB), AX
MOVQ AX, ret+0(FP)
RET
// func counterVal() int64
TEXT ·counterVal(SB), NOSPLIT, $0-8
MOVQ counter(SB), AX
MOVQ AX, 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
+57
View File
@@ -0,0 +1,57 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (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
+56
View File
@@ -0,0 +1,56 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
#include "textflag.h"
// The link-regression kernel for loong64, the amd64 one's sibling:
// stack discipline (add), an intra-file call (probe calling seven,
// R_CALLLOONG64), a PCALAU12I pair against static data (word<>,
// R_LOONG64_ADDR_HI/LO), 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 (R3), the loong64 ABI0 frame convention.
// func add(a, b int64) int64
TEXT ·add(SB), NOSPLIT, $0-24
MOVV a+0(FP), R4
MOVV b+8(FP), R5
ADDV R5, R4, R4
MOVV R4, ret+16(FP)
RET
// func seven() int64
TEXT ·seven(SB), NOSPLIT, $0-8
MOVV $7, R4
MOVV R4, ret+0(FP)
RET
// func probe() int64 = seven() + word<>(SB)
TEXT ·probe(SB), NOSPLIT, $8-8
CALL ·seven(SB)
MOVV 8(R3), R4
MOVV word<>(SB), R5
ADDV R5, R4, R4
MOVV R4, ret+0(FP)
RET
// func entryAddr() uintptr
TEXT ·entryAddr(SB), NOSPLIT, $0-8
MOVV entry(SB), R4
MOVV R4, ret+0(FP)
RET
// func counterVal() int64
TEXT ·counterVal(SB), NOSPLIT, $0-8
MOVV counter(SB), R4
MOVV 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
+56
View File
@@ -0,0 +1,56 @@
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: BSD-3-Clause
#include "textflag.h"
// The link-regression kernel for riscv64, the amd64 one's sibling: stack
// discipline (add), an intra-file call (probe calling seven, the
// R_RISCV_CALL pair), an AUIPC+I-type pair against static data (word<>,
// R_RISCV_PCREL_ITYPE), 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 riscv64 ABI0 frame convention.
// func add(a, b int64) int64
TEXT ·add(SB), NOSPLIT, $0-24
MOV a+0(FP), X10
MOV b+8(FP), X11
ADD X11, X10, X10
MOV X10, ret+16(FP)
RET
// func seven() int64
TEXT ·seven(SB), NOSPLIT, $0-8
MOV $7, X10
MOV X10, ret+0(FP)
RET
// func probe() int64 = seven() + word<>(SB)
TEXT ·probe(SB), NOSPLIT, $8-8
CALL ·seven(SB)
MOV 8(SP), X10
MOV word<>(SB), X11
ADD X11, X10, X10
MOV X10, ret+0(FP)
RET
// func entryAddr() uintptr
TEXT ·entryAddr(SB), NOSPLIT, $0-8
MOV entry(SB), X10
MOV X10, ret+0(FP)
RET
// func counterVal() int64
TEXT ·counterVal(SB), NOSPLIT, $0-8
MOV counter(SB), X10
MOV X10, 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