From db4c8e52d5fdfbc5abe2aeb5103c4058f250c585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 21 Apr 2025 17:38:03 +0200 Subject: [PATCH] add a testscript with the linknames that bytedance/sonic/loader has For #898. --- testdata/script/linkname.txtar | 2 +- testdata/script/linkname_forbid.txtar | 30 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 testdata/script/linkname_forbid.txtar diff --git a/testdata/script/linkname.txtar b/testdata/script/linkname.txtar index 03c239a..0dd794c 100644 --- a/testdata/script/linkname.txtar +++ b/testdata/script/linkname.txtar @@ -190,4 +190,4 @@ renamed func featuring Dante from the Devil May Cry series 3 obfuscated func -to this \ No newline at end of file +to this diff --git a/testdata/script/linkname_forbid.txtar b/testdata/script/linkname_forbid.txtar new file mode 100644 index 0000000..2c2b95c --- /dev/null +++ b/testdata/script/linkname_forbid.txtar @@ -0,0 +1,30 @@ +# TODO: Disallow certain kinds of runtime linknaming which break with garble. + +exec garble build +exec ./main + +[short] stop # no need to verify this with -short + +go build +exec ./main + +-- go.mod -- +module test/main + +go 1.23 +-- linkname_runtime.go -- +package main + +import _ "unsafe" + +// Note that it doesn't matter that the struct here is empty, +// as the linknames below only use pointers to it. +type moduledata struct {} + +//go:linkname lastmoduledatap runtime.lastmoduledatap +var lastmoduledatap *moduledata + +//go:linkname moduledataverify1 runtime.moduledataverify1 +func moduledataverify1(_ *moduledata) + +func main() {}