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.
44 lines
1.5 KiB
Diff
44 lines
1.5 KiB
Diff
From 16b978956b323d88ef4a48dbef124304f5206e90 Mon Sep 17 00:00:00 2001
|
|
From: pagran <pagran@protonmail.com>
|
|
Date: Sat, 14 Jan 2023 21:36:16 +0100
|
|
Subject: [PATCH 3/3] add entryOff encryption
|
|
|
|
---
|
|
cmd/link/internal/ld/pcln.go | 20 ++++++++++++++++++++
|
|
1 file changed, 20 insertions(+)
|
|
|
|
diff --git a/cmd/link/internal/ld/pcln.go b/cmd/link/internal/ld/pcln.go
|
|
index c47b9eab72..d58338f7c3 100644
|
|
--- a/cmd/link/internal/ld/pcln.go
|
|
+++ b/cmd/link/internal/ld/pcln.go
|
|
@@ -980,6 +980,26 @@ func writeFuncs(ctxt *Link, sb *loader.SymbolBuilder, funcs []loader.Sym, inlSym
|
|
sb.SetUint32(ctxt.Arch, dataoff, uint32(ldr.SymValue(fdsym)))
|
|
}
|
|
}
|
|
+
|
|
+ // Moving next code higher is not recommended.
|
|
+ // Only at the end of the current function no edits between go versions
|
|
+ garbleEntryOffKeyStr := os.Getenv("GARBLE_LINK_ENTRYOFF_KEY")
|
|
+ if garbleEntryOffKeyStr == "" {
|
|
+ panic("[garble] entryOff key must be set")
|
|
+ }
|
|
+ var garbleEntryOffKey uint32
|
|
+ // Use fmt package instead of strconv to avoid importing a new package
|
|
+ if _, err := fmt.Sscan(garbleEntryOffKeyStr, &garbleEntryOffKey); err != nil {
|
|
+ panic(fmt.Errorf("[garble] invalid entryOff key %s: %v", garbleEntryOffKeyStr, err))
|
|
+ }
|
|
+
|
|
+ garbleData := sb.Data()
|
|
+ for _, off := range startLocations {
|
|
+ entryOff := ctxt.Arch.ByteOrder.Uint32(garbleData[off:])
|
|
+ nameOff := ctxt.Arch.ByteOrder.Uint32(garbleData[off+4:])
|
|
+
|
|
+ sb.SetUint32(ctxt.Arch, int64(off), entryOff^(nameOff*garbleEntryOffKey))
|
|
+ }
|
|
}
|
|
|
|
// pclntab initializes the pclntab symbol with
|
|
--
|
|
2.53.0
|
|
|