From 0b096c9e7544bfb118f5f5acfb3d6d4daa3902f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 24 Jan 2023 16:33:46 +0000 Subject: [PATCH] generate go_std_tables.go in its entirety No more having to manually run the script and adapting it to Go code. --- go_std_tables.go | 9 ++++--- scripts/gen-go-std-tables.sh | 38 +++++++++++++++++++++++++++++ scripts/runtime-linknamed-nodeps.sh | 11 --------- shared.go | 2 ++ 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100755 scripts/gen-go-std-tables.sh delete mode 100755 scripts/runtime-linknamed-nodeps.sh diff --git a/go_std_tables.go b/go_std_tables.go index b988c27..4ab9707 100644 --- a/go_std_tables.go +++ b/go_std_tables.go @@ -1,13 +1,16 @@ +// Code generated by scripts/gen-go-std-tables.sh; DO NOT EDIT. + +// Generated from Go version devel go1.21-733ba92187 Tue Jan 24 13:28:54 2023 +0000. + package main -// Obtained from "go list -deps runtime" as of June 29th. -// Note that the same command on Go 1.18 results in the same list. var runtimeAndDeps = map[string]bool{ "internal/goarch": true, "unsafe": true, "internal/abi": true, "internal/cpu": true, "internal/bytealg": true, + "internal/coverage/rtcov": true, "internal/goexperiment": true, "internal/goos": true, "runtime/internal/atomic": true, @@ -17,7 +20,6 @@ var runtimeAndDeps = map[string]bool{ "runtime": true, } -// Obtained via scripts/runtime-linknamed-nodeps.sh as of 2022-11-01. var runtimeLinknamed = []string{ "arena", "crypto/internal/boring", @@ -37,6 +39,7 @@ var runtimeLinknamed = []string{ "runtime/coverage", "runtime/debug", "runtime/metrics", + "runtime/metrics_test", "runtime/pprof", "runtime/trace", "sync", diff --git a/scripts/gen-go-std-tables.sh b/scripts/gen-go-std-tables.sh new file mode 100755 index 0000000..4b76daa --- /dev/null +++ b/scripts/gen-go-std-tables.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# We can rewrite this bash script in Go if a dependency on bash and coreutils +# is a problem during development. + +go_version=$(go env GOVERSION) # not "go version", to exclude GOOS/GOARCH + +runtime_and_deps=$(go list -deps runtime) + +# All packages that the runtime linknames to, except runtime and its dependencies. +# This resulting list is what we need to "go list" when obfuscating the runtime, +# as they are the packages that we may be missing. +runtime_linknamed=$(comm -23 <( + sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.' | sort -u +) <( + # Note that we assume this is constant across platforms. + go list -deps runtime | sort -u +)) + +gofmt >go_std_tables.go <