forked from burrowers/garble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add and test initial support for Go 1.22
The Go 1.21 linker patches luckily rebased on master as of de5b418bea70aaf27de1f47e9b5813940d1e15a4 just fine. The addition of the strings import in the second patch was removed, since the file in Go 1.22 now has this package import. We can remove the Go 1.20 linker patches too, since we no longer support that Go version in the upcoming release. Start treating runtime/internal/startlinetest as part of the runtime, since otherwise its test-only trickery breaks "garble build std": # runtime/internal/startlinetest [...]/XS7r7lPHkTG.s:23: ABI selector only permitted when compiling runtime, reference was to "HGoWHDsKwh.AlfA2or7Nnb" asm: assembly of $WORK/.tmp/garble-shared1535203339/HGoWHDsKwh/XS7r7lPHkTG.s failed While here, update actions/checkout and staticcheck in CI.
- Loading branch information
Showing
8 changed files
with
107 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 0 additions & 73 deletions
73
internal/linker/patches/go1.20/0002-add-unexported-function-name-removing.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
internal/linker/patches/go1.22/0002-add-unexported-function-name-removing.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
From fef657296f1f1b51b73b4e715af4ce9569d05bae Mon Sep 17 00:00:00 2001 | ||
From: pagran <pagran@protonmail.com> | ||
Date: Mon, 9 Jan 2023 13:30:36 +0100 | ||
Subject: [PATCH 2/3] add unexported function name removing | ||
|
||
--- | ||
cmd/link/internal/ld/pcln.go | 43 +++++++++++++++++++++++++++++++++++- | ||
1 file changed, 42 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/cmd/link/internal/ld/pcln.go b/cmd/link/internal/ld/pcln.go | ||
index 0f95ad928b..6bfa03da87 100644 | ||
--- a/cmd/link/internal/ld/pcln.go | ||
+++ b/cmd/link/internal/ld/pcln.go | ||
@@ -4,6 +4,10 @@ | ||
|
||
package ld | ||
|
||
+import ( | ||
+ "unicode" | ||
+) | ||
+ | ||
import ( | ||
"cmd/internal/goobj" | ||
"cmd/internal/objabi" | ||
@@ -315,19 +319,56 @@ func walkFuncs(ctxt *Link, funcs []loader.Sym, f func(loader.Sym)) { | ||
func (state *pclntab) generateFuncnametab(ctxt *Link, funcs []loader.Sym) map[loader.Sym]uint32 { | ||
nameOffsets := make(map[loader.Sym]uint32, state.nfunc) | ||
|
||
+ garbleTiny := os.Getenv("GARBLE_LINK_TINY") == "true" | ||
+ | ||
// Write the null terminated strings. | ||
writeFuncNameTab := func(ctxt *Link, s loader.Sym) { | ||
symtab := ctxt.loader.MakeSymbolUpdater(s) | ||
+ if garbleTiny { | ||
+ symtab.AddStringAt(0, "") | ||
+ } | ||
+ | ||
for s, off := range nameOffsets { | ||
+ if garbleTiny && off == 0 { | ||
+ continue | ||
+ } | ||
symtab.AddCStringAt(int64(off), ctxt.loader.SymName(s)) | ||
} | ||
} | ||
|
||
// Loop through the CUs, and calculate the size needed. | ||
var size int64 | ||
+ | ||
+ if garbleTiny { | ||
+ size = 1 // first byte is reserved for empty string used for all non-exportable method names | ||
+ } | ||
+ // Kinds of SymNames found in the wild: | ||
+ // | ||
+ // * reflect.Value.CanAddr | ||
+ // * reflect.(*Value).String | ||
+ // * reflect.w6cEoKc | ||
+ // * internal/abi.(*RegArgs).IntRegArgAddr | ||
+ // * type:.eq.runtime.special | ||
+ // * runtime/internal/atomic.(*Pointer[go.shape.string]).Store | ||
+ // | ||
+ // Checking whether the first rune after the last dot is uppercase seems enough. | ||
+ isExported := func(name string) bool { | ||
+ for _, r := range name[strings.LastIndexByte(name, '.')+1:] { | ||
+ return unicode.IsUpper(r) | ||
+ } | ||
+ return false | ||
+ } | ||
+ | ||
walkFuncs(ctxt, funcs, func(s loader.Sym) { | ||
+ name := ctxt.loader.SymName(s) | ||
+ | ||
+ if garbleTiny && !isExported(name) { | ||
+ nameOffsets[s] = 0 // redirect name to empty string | ||
+ return | ||
+ } | ||
+ | ||
nameOffsets[s] = uint32(size) | ||
- size += int64(len(ctxt.loader.SymName(s)) + 1) // NULL terminate | ||
+ size += int64(len(name) + 1) // NULL terminate | ||
}) | ||
|
||
state.funcnametab = state.addGeneratedSym(ctxt, "runtime.funcnametab", size, writeFuncNameTab) | ||
-- | ||
2.43.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters