feat(lint): flag writes to the platform-reserved register

This commit is contained in:
2026-08-30 21:42:12 +02:00
parent 62f6fb4faf
commit 75bd83fd52
4 changed files with 126 additions and 0 deletions
+7
View File
@@ -81,6 +81,7 @@ const (
CodeABI0RegisterArgs = "abi0-register-args"
CodeNonportableRegister = "nonportable-register-name"
CodeUnencodable = "unencodable-instruction"
CodeReservedRegister = "reserved-register-write"
)
// knownTextFlags are the flags recognised by the Go assembler's textflag.h.
@@ -469,6 +470,12 @@ func lintText(t *ast.Text, tab *arch.Table, archKnown bool, cfg Config, macros m
out = append(out, scanNonportableRegisters(t)...)
}
// Writes to the platform-reserved register (arm64 R18), which the ABI
// checks cannot observe at runtime.
if cfg.Arch == arch.ARM64 && !hasMacro && !cfg.Disable[CodeReservedRegister] {
out = append(out, scanReservedRegisterWrites(t, cfg.Arch)...)
}
// FUNCDATA / PCDATA structural validation.
out = append(out, checkFuncdata(t, cfg)...)