mirror of
https://github.com/burrowers/garble.git
synced 2026-04-22 15:47:04 +08:00
7114403786
Beyond the usual updating of version strings, re-running `go generate`, and updating the patches for the linker, we needed extra changes. First, the linker started being stricter about which packages are allowed to linkname runtime names by import path. Stop obfuscating import paths in runtimeAndLinknamed. Second, the compiler's intrinsics code adds an "add" function much like the existing "addF", so tweak the regular expression. Third, note that there is a new runtimeAndDeps windows-only package, which we find thanks to the recent improvement to cover many platforms. Fourth, the code around magic numbers in the runtime has changed, so rewrite the code which patches it via go/ast. Fixes #990.
48 lines
1.3 KiB
Diff
48 lines
1.3 KiB
Diff
From b59e8e940e82f488d5d688277046f6cd87c75908 Mon Sep 17 00:00:00 2001
|
|
From: pagran <pagran@protonmail.com>
|
|
Date: Mon, 9 Jan 2023 13:30:00 +0100
|
|
Subject: [PATCH 1/3] add custom magic value
|
|
|
|
---
|
|
cmd/link/internal/ld/pcln.go | 17 +++++++++++++++++
|
|
1 file changed, 17 insertions(+)
|
|
|
|
diff --git a/cmd/link/internal/ld/pcln.go b/cmd/link/internal/ld/pcln.go
|
|
index 08c4d4db83..ffe8fdf7a1 100644
|
|
--- a/cmd/link/internal/ld/pcln.go
|
|
+++ b/cmd/link/internal/ld/pcln.go
|
|
@@ -4,6 +4,10 @@
|
|
|
|
package ld
|
|
|
|
+import (
|
|
+ "os"
|
|
+)
|
|
+
|
|
import (
|
|
"cmd/internal/goobj"
|
|
"cmd/internal/objabi"
|
|
@@ -282,6 +286,19 @@ func (state *pclntab) generatePCHeader(ctxt *Link) {
|
|
if off != size {
|
|
panic(fmt.Sprintf("pcHeader size: %d != %d", off, size))
|
|
}
|
|
+
|
|
+ // Use garble prefix in variable names to minimize collision risk
|
|
+ garbleMagicStr := os.Getenv("GARBLE_LINK_MAGIC")
|
|
+ if garbleMagicStr == "" {
|
|
+ panic("[garble] magic value must be set")
|
|
+ }
|
|
+ var garbleMagicVal uint32
|
|
+ // Use fmt package instead of strconv to avoid importing a new package
|
|
+ if _, err := fmt.Sscan(garbleMagicStr, &garbleMagicVal); err != nil {
|
|
+ panic(fmt.Errorf("[garble] invalid magic value %s: %v", garbleMagicStr, err))
|
|
+ }
|
|
+
|
|
+ header.SetUint32(ctxt.Arch, 0, garbleMagicVal)
|
|
}
|
|
|
|
state.pcheader = state.addGeneratedSym(ctxt, "runtime.pcheader", size, int32(ctxt.Arch.PtrSize), writeHeader)
|
|
--
|
|
2.53.0
|
|
|