feat(lint): eleven new rules over directives, data and addressing

Assisted-by: GLM 5.3
This commit is contained in:
2026-10-02 00:40:54 +02:00
parent f405cea5bc
commit 69dcbec8ef
12 changed files with 1431 additions and 19 deletions
+66 -4
View File
@@ -1,4 +1,4 @@
.TH GASM-LINT 1 "2026-09-19" "gasm" "User Commands"
.TH GASM-LINT 1 "2026-10-01" "gasm" "User Commands"
.SH NAME
gasm-lint \- run the static checks over assembly files
.SH SYNOPSIS
@@ -27,7 +27,11 @@ A jump target names no label in the function.
Two labels in one function share a name.
.TP
.B missing-ret
The function can fall off its end without a terminator.
The function has no RET, or has one but can still fall off its end: the
last instruction is neither RET nor an unconditional branch, so execution
continues into the next TEXT. Trailing labels, GC annotations and
padding are skipped, and traps (INT on amd64, BRK on arm64) count as
terminators.
.TP
.B missing-textflag-include
TEXT flags are used without including textflag.h.
@@ -56,8 +60,9 @@ FUNCDATA and PCDATA indices are malformed.
A label no jump reaches.
.TP
.B invalid-textflag
An unknown TEXT or GLOBL flag, reported one flag at a time; numeric flags
are accepted as textflag.h constants.
An unknown TEXT or GLOBL flag, or a known one misplaced (NOSPLIT on
GLOBL, RODATA on TEXT), reported one flag at a time; numeric flags are
accepted as textflag.h constants.
.TP
.B stack-imbalance
The function does not restore the stack pointer on every path.
@@ -85,6 +90,63 @@ yet (amd64).
.TP
.B reserved-register-write
A write to the register the runtime reserves (arm64 R18).
.TP
.B missing-argsize
A TEXT without NOSPLIT omits the argument area its
.B //\ function
signature implies; the object then records ArgsSizeUnknown and go vet
skips the size check.
.TP
.B noframe-frame-size
The NOFRAME flag against a positive frame size; NOFRAME is the
zero-frame spelling, and the negative frames of the arm64 BSD syscall
stubs are exempt.
.TP
.B unnamed-fp-reference
A numeric offset against FP, written
.IR 0(FP) ;
the assembler requires
.IR name+offset(FP) .
.TP
.B hardware-sp-addressing
A negative numeric offset against
.IR (SP) ,
which addresses the hardware stack pointer rather than the named
virtual frame; the runtime's deliberate hardware-SP references all
carry positive offsets.
.TP
.B vex-sse-mixing
VEX-encoded instructions and legacy SSE on X registers in one function;
each switch between the encodings pays a transition penalty
(informational).
.TP
.B unnamed-result
A result slot addressed with the generic
.I ret
spelling although the
.B //\ function
signature names the result (a hint).
.TP
.B data-width
A DATA width its value cannot take: 1, 2, 4 or 8 for an integer, 4 or 8
for a float, and the suffix itself is never optional; a string accepts
any width.
.TP
.B data-value-overflow
An integer initialiser wider than its DATA field; both assemblers
truncate it silently to the low bytes.
.TP
.B data-string-width
A string initialiser longer than its DATA field; both assemblers reject
it.
.TP
.B data-without-globl
A DATA initialiser whose symbol has no GLOBL declaration in the file;
gasm asm requires the pairing, go tool asm sizes the symbol implicitly.
.TP
.B data-exceeds-globl
A DATA initialiser writing past the GLOBL-declared size; go tool asm
grows the symbol silently, gasm asm rejects the file.
.SH OPTIONS
.TP
.B \-disable \fIcodes\fR