Obfuscate more packages of the standard library (#312)
Also update linkname directives of public packages, to allow the package where something is linknamed to to be obfuscated regardless. Public packages can now depend on private packages.pull/407/head
parent
e7320ec9c0
commit
88f238e558
@ -1,19 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script is hacky, but lets us list all packages depended on by runtime, or
|
||||
# related to runtime via go:linkname.
|
||||
#
|
||||
# Once we can obfuscate the runtime package, this script can probably be
|
||||
# deleted.
|
||||
|
||||
go version
|
||||
echo
|
||||
|
||||
for GOOS in linux darwin windows; do
|
||||
skip="|macos"
|
||||
if [[ $GOOS == "darwin" ]]; then
|
||||
skip=""
|
||||
fi
|
||||
|
||||
GOOS=$GOOS go list -deps $(sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.|js'$skip) runtime || exit 1
|
||||
done | sort -u
|
@ -0,0 +1,55 @@
|
||||
# test that we used all necessary dependencies
|
||||
[linux] exec bash runtime-related-tested.sh
|
||||
|
||||
env GOPRIVATE=*
|
||||
garble build
|
||||
|
||||
-- runtime-related.sh --
|
||||
for GOOS in linux darwin windows; do
|
||||
skip="|macos"
|
||||
if [[ $GOOS == "darwin" ]]; then
|
||||
skip=""
|
||||
fi
|
||||
|
||||
GOOS=$GOOS go list -deps $(sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.|js'$skip) runtime || exit 1
|
||||
done | sort -u
|
||||
|
||||
-- runtime-related-tested.sh --
|
||||
# get all runtime-related deps
|
||||
related=$(bash runtime-related.sh) || exit 1
|
||||
|
||||
# get all tested deps
|
||||
tested=$(for GOOS in linux darwin windows; do GOOS=$GOOS go list -deps || exit 1; done | sort -u)
|
||||
|
||||
# remove all tested deps from the runtime-related deps
|
||||
output=$(echo "$related" | grep -Fvx -e "$tested")
|
||||
|
||||
# output should be empty if all runtime-related deps are tested
|
||||
[[ -z "$output" ]] || (echo "$output" && exit 1)
|
||||
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.17
|
||||
|
||||
-- main.go --
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http/pprof"
|
||||
"os/signal"
|
||||
"plugin"
|
||||
"runtime/debug"
|
||||
"runtime/metrics"
|
||||
"text/tabwriter"
|
||||
)
|
||||
|
||||
// This program imports all runtime-related dependencies (proven by runtime-related-tested.sh)
|
||||
func main() {
|
||||
_ = tabwriter.AlignRight
|
||||
signal.Ignore()
|
||||
_ = plugin.Plugin{}
|
||||
_ = pprof.Handler("")
|
||||
_ = debug.GCStats{}
|
||||
metrics.All()
|
||||
}
|
Loading…
Reference in New Issue