Move from facts render to facts validation.

This allows fact information to be validated in the underlying source files,
but requires us to explicitly maintain this in appropriate version-tagged, and
architecture-tagged files. This is more explicit and safer.

This mechanism uses a special regular expression for matching a +checkconst
stanza to validate constant values, sizes and offsets. This applies to both Go
source files and assembly files.

PiperOrigin-RevId: 511867507
This commit is contained in:
Adin Scannell
2023-02-23 13:17:49 -08:00
committed by gVisor bot
parent 5817f4cc64
commit bd561fd3f9
33 changed files with 646 additions and 952 deletions
+2 -19
View File
@@ -1,30 +1,13 @@
load("//tools:arch.bzl", "arch_genrule", "select_arch")
load("//tools:defs.bzl", "go_library", "go_test")
load("//tools/nogo:defs.bzl", "nogo_facts")
package(licenses = ["notice"])
nogo_facts(
name = "hosttid_impl",
srcs = ["hosttid.go"],
output = "hosttid_impl.s",
template = select_arch(
amd64 = "hosttid_amd64.s",
arm64 = "hosttid_arm64.s",
),
)
arch_genrule(
name = "hosttid_impl_arch",
src = ":hosttid_impl",
template = "hosttid_impl_%s.s",
)
go_library(
name = "hosttid",
srcs = [
"hosttid.go",
":hosttid_impl_arch",
"hosttid_amd64.s",
"hosttid_arm64.s",
],
visibility = ["//visibility:public"],
)
+2 -2
View File
@@ -17,8 +17,8 @@
#include "textflag.h"
#define M_OFFSET {{ .import.runtime.g.m.Offset }}
#define PROCID_OFFSET {{ .import.runtime.m.procid.Offset }}
#define M_OFFSET 48 // +checkoffset runtime g.m
#define PROCID_OFFSET 72 // +checkoffset runtime m.procid
TEXT ·Current(SB),NOSPLIT,$0-8
// procid is in getg().m.procid.
+2 -2
View File
@@ -17,8 +17,8 @@
#include "textflag.h"
#define M_OFFSET {{ .import.runtime.g.m.Offset }}
#define PROCID_OFFSET {{ .import.runtime.m.procid.Offset }}
#define M_OFFSET 48 // +checkoffset runtime g.m
#define PROCID_OFFSET 72 // +checkoffset runtime m.procid
TEXT ·Current(SB),NOSPLIT,$0-8
// procid is in getg().m.procid.