feat(asm): symbol-valued DATA, division slash in symbols and plain semicolons

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-20 19:15:05 +02:00
parent 289cabe993
commit 6556b85abf
14 changed files with 1027 additions and 18 deletions
+25
View File
@@ -0,0 +1,25 @@
#include "textflag.h"
// The kernel exercises the symbol-valued DATA spelling the runtime's rt0
// files use: a data word holding the address of a symbol, resolved by the
// linker through a relocation at the field.
// func lookup() ptr
TEXT ·lookup(SB), NOSPLIT, $0-8
MOVQ handlers+8(SB), AX
MOVQ AX, ret+0(FP)
RET
// func handler() int64
TEXT ·handler(SB), NOSPLIT, $0-8
MOVQ $42, AX
MOVQ AX, ret+0(FP)
RET
GLOBL handlers(SB), NOPTR, $24
DATA handlers+0(SB)/8, $·handler(SB)
DATA handlers+8(SB)/8, $table(SB)
DATA handlers+16(SB)/8, $·handler+5(SB)
GLOBL table(SB), RODATA, $8
DATA table+0(SB)/8, $0x123456789abcdef0
+25
View File
@@ -0,0 +1,25 @@
#include "textflag.h"
// The kernel exercises the symbol-valued DATA spelling the runtime's rt0
// files use: a data word holding the address of a symbol, resolved by the
// linker through a relocation at the field.
// func lookup() ptr
TEXT ·lookup(SB), NOSPLIT, $0-8
MOVD handlers+8(SB), R4
MOVD R4, ret+0(FP)
RET
// func handler() int64
TEXT ·handler(SB), NOSPLIT, $0-8
MOVZ $42, R4
MOVD R4, ret+0(FP)
RET
GLOBL handlers(SB), NOPTR, $24
DATA handlers+0(SB)/8, $·handler(SB)
DATA handlers+8(SB)/8, $table(SB)
DATA handlers+16(SB)/8, $extentry(SB)
GLOBL table(SB), RODATA, $8
DATA table+0(SB)/8, $0x123456789abcdef0
+19
View File
@@ -0,0 +1,19 @@
#include "textflag.h"
// The kernel exercises the U+2215 DIVISION SLASH inside a symbol's package
// path: internal∕runtime∕atomic·Xchg, the spelling sync/atomic/asm.s uses.
// The middle dot (U+00B7) still separates the package path from the name.
// func swap(a, b int64) int64
TEXT ·swap(SB), NOSPLIT, $0-24
MOVQ a+0(FP), DI
MOVQ b+8(FP), SI
CALL internal∕runtime∕atomic·Xchg(SB)
MOVQ AX, ret+16(FP)
RET
// func note() int64
TEXT ·note(SB), NOSPLIT, $0-8
CALL runtime∕debug·SetGCPercent(SB)
MOVQ AX, ret+0(FP)
RET
+19
View File
@@ -0,0 +1,19 @@
#include "textflag.h"
// The kernel exercises the U+2215 DIVISION SLASH inside a symbol's package
// path: internal∕runtime∕atomic·Xchg, the spelling sync/atomic/asm.s uses.
// The middle dot (U+00B7) still separates the package path from the name.
// func swap(a, b int64) int64
TEXT ·swap(SB), NOSPLIT, $0-24
MOVD a+0(FP), R4
MOVD b+8(FP), R5
CALL internal∕runtime∕atomic·Xchg(SB)
MOVD R4, ret+16(FP)
RET
// func note() int64
TEXT ·note(SB), NOSPLIT, $0-8
CALL runtime∕debug·SetGCPercent(SB)
MOVD R0, ret+0(FP)
RET
+21
View File
@@ -0,0 +1,21 @@
#include "textflag.h"
// The kernel exercises the ';' statement separator in a plain file, the way
// the runtime writes it ("ROLQ $3, DI; ROLQ $13, DI", "REP; MOVSQ"). Each
// statement assembles exactly as it would on a line of its own.
// func rol(x int64) int64
TEXT ·rol(SB), NOSPLIT, $0-16
ROLQ $3, DI; ROLQ $13, DI
MOVQ DI, ret+0(FP)
RET
// func move(dst, src unsafe.Pointer)
TEXT ·move(SB), NOSPLIT, $0-16
REP ; MOVSQ
RET
TEXT ·paired(SB), NOSPLIT, $0-8
XORQ AX, AX; XORQ CX, CX
MOVQ AX, ret+0(FP)
RET