You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
Diff
48 lines
1.3 KiB
Diff
From 1eb3d02d33155831067ca7db2c6517108c4305ae 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 ea08fd3d31..7bae9f18c5 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"
|
|
@@ -262,6 +266,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, writeHeader)
|
|
--
|
|
2.48.1
|
|
|