feat(lint): eleven new rules over directives, data and addressing
Assisted-by: GLM 5.3
This commit is contained in:
+12
-5
@@ -131,8 +131,11 @@ Rules: `unknown-instruction`, `operand-count`, `undefined-label`,
|
||||
`abi-argsize`, `unreachable-code`, `register-clobber`,
|
||||
`funcdata-pcdata`, `unused-label`, `invalid-textflag`,
|
||||
`stack-imbalance`, `register-width-mismatch`, `abi0-register-args`,
|
||||
`nonportable-register-name`, `unencodable-instruction` and
|
||||
`reserved-register-write`.
|
||||
`nonportable-register-name`, `unencodable-instruction`,
|
||||
`reserved-register-write`, `missing-argsize`, `noframe-frame-size`,
|
||||
`unnamed-fp-reference`, `hardware-sp-addressing`, `vex-sse-mixing`,
|
||||
`unnamed-result`, `data-width`, `data-value-overflow`,
|
||||
`data-string-width`, `data-without-globl` and `data-exceeds-globl`.
|
||||
|
||||
```sh
|
||||
gasm lint kernel_amd64.s
|
||||
@@ -455,14 +458,18 @@ Provides: completion, hover, document symbols, push and pull diagnostics,
|
||||
semantic tokens, go-to-definition, find references, rename, document
|
||||
formatting, inlay hints, code actions, signature help, document highlights,
|
||||
workspace symbol search, #include document links, and folding ranges for
|
||||
function bodies. Definition, references and rename work across every open
|
||||
function bodies. Completion offers the architecture's registers and
|
||||
instructions, the TEXT/DATA/GLOBL directives, the annotation and padding
|
||||
pseudo-ops (PCALIGN, FUNCDATA, PCDATA, the BYTE family) and the textflag
|
||||
constants; hover documents mnemonics, registers, pseudo-registers and the
|
||||
directives. Definition, references and rename work across every open
|
||||
document and the wider workspace on disk: the server indexes the `.s` files
|
||||
under the workspace root that the editor has never opened, an open buffer
|
||||
always shadows its disk copy, and watched-file events together with a
|
||||
per-query freshness check keep the index current. The quick fixes add the
|
||||
missing `#include "textflag.h"`, set the TEXT argument area to the size the
|
||||
`// func` signature implies, add a missing `RET`, and remove an unused
|
||||
label.
|
||||
`// func` signature implies, declare that area when it is omitted entirely,
|
||||
add a missing `RET`, and remove an unused label.
|
||||
|
||||
## version
|
||||
|
||||
|
||||
+66
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user