From c0e1bab5e9ebfb6435f888e79cbce8d73a528a60 Mon Sep 17 00:00:00 2001 From: "bot-for-go[bot]" <199222863+bot-for-go[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 16:11:12 +0000 Subject: [PATCH 1/4] Update submodule to latest master (e30e65f7): syscall,runtime/cgo: use cgo_ldflag to link against -lsocket and -lxnet on Solaris --- go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go b/go index cbab448de1..e30e65f7a8 160000 --- a/go +++ b/go @@ -1 +1 @@ -Subproject commit cbab448de1c562e417b179d29f99758f4680630b +Subproject commit e30e65f7a8bda0351d9def5a6bc91471bddafd3d From 593de1c42fb294149a84613f95a02f4bb8cfd41f Mon Sep 17 00:00:00 2001 From: George Adams Date: Wed, 11 Mar 2026 16:46:28 +0000 Subject: [PATCH 2/4] resolve 3-way merge conflicts --- ...013-Add-Microsoft-version-information.patch | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/patches/0013-Add-Microsoft-version-information.patch b/patches/0013-Add-Microsoft-version-information.patch index c9446d530c..36aa56baf6 100644 --- a/patches/0013-Add-Microsoft-version-information.patch +++ b/patches/0013-Add-Microsoft-version-information.patch @@ -31,10 +31,10 @@ Microsoft build of Go version string. create mode 100644 src/cmd/go/testdata/script/gotoolchain_local_ms.txt diff --git a/doc/godebug.md b/doc/godebug.md -index 4c95ceb09bcbbe..6b052d8ce29b6a 100644 +index beee0f46498d4d..f2eb13d1dde4d4 100644 --- a/doc/godebug.md +++ b/doc/godebug.md -@@ -192,6 +192,15 @@ Microsoft build of Go 1.26 added a new `ms_tlsprofile` setting that controls the +@@ -218,6 +218,15 @@ Microsoft build of Go 1.26 added a new `ms_tlsprofile` setting that controls the - "default": use the recommended Microsoft TLS settings. This is the default. - "off": use the default upstream Go TLS settings. @@ -51,7 +51,7 @@ index 4c95ceb09bcbbe..6b052d8ce29b6a 100644 Go 1.25 added a new `decoratemappings` setting that controls whether the Go diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go -index 917f682fd4bfaf..85512e38220de6 100644 +index feef0080cb12d6..e9b74bd4abf191 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -450,6 +450,22 @@ func findgoversion() string { @@ -334,10 +334,10 @@ index 00000000000000..24538695be2cf2 +go version +stdout go1.501 diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go -index 0140c385e47991..727a992bdf7a11 100644 +index 24fecd47360a8d..cb4b51df2aeebd 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go -@@ -186,15 +186,20 @@ func Main(arch *sys.Arch, theArch Arch) { +@@ -188,15 +188,20 @@ func Main(arch *sys.Arch, theArch Arch) { addstrdata1(ctxt, "runtime.defaultGOROOT="+buildcfg.GOROOT) } @@ -364,7 +364,7 @@ index 0140c385e47991..727a992bdf7a11 100644 // TODO(matloob): define these above and then check flag values here if ctxt.Arch.Family == sys.AMD64 && buildcfg.GOOS == "plan9" { -@@ -210,10 +215,28 @@ func Main(arch *sys.Arch, theArch Arch) { +@@ -212,10 +217,28 @@ func Main(arch *sys.Arch, theArch Arch) { objabi.Flagfn1("X", "add string value `definition` of the form importpath.name=value", func(s string) { addstrdata1(ctxt, s) }) objabi.Flagcount("v", "print link trace", &ctxt.Debugvlog) objabi.Flagfn1("importcfg", "read import configuration from `file`", ctxt.readImportCfg) @@ -443,7 +443,7 @@ index 89fd74eb823162..f6d6a78531fc75 100644 var Error error diff --git a/src/internal/godebugs/table.go b/src/internal/godebugs/table.go -index 7a5ea67c7dca33..d3e5b7b71d528c 100644 +index 1ba17bc136710f..a3868ad860ed4a 100644 --- a/src/internal/godebugs/table.go +++ b/src/internal/godebugs/table.go @@ -51,6 +51,7 @@ var All = []Info{ @@ -495,7 +495,7 @@ index a9f97a1a045525..991d5ef22c5df5 100644 // GOOS is the running program's operating system target: diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go -index 965ff8ab5167d5..2674b5d8844b18 100644 +index 10754eee1cd999..20ce0d57d003bd 100644 --- a/src/runtime/runtime1.go +++ b/src/runtime/runtime1.go @@ -364,6 +364,9 @@ var debug struct { @@ -509,7 +509,7 @@ index 965ff8ab5167d5..2674b5d8844b18 100644 var dbgvars = []*dbgVar{ @@ -401,6 +404,7 @@ var dbgvars = []*dbgVar{ - {name: "tracebacklabels", atomic: &debug.tracebacklabels, def: 0}, + {name: "tracebacklabels", atomic: &debug.tracebacklabels, def: 1}, {name: "tracefpunwindoff", value: &debug.tracefpunwindoff}, {name: "updatemaxprocs", value: &debug.updatemaxprocs, def: 1}, + {name: "ms_version", atomic: &debug.msversion, def: 0}, From 6729d545e61b826b7766a4d454839b2ead30ec79 Mon Sep 17 00:00:00 2001 From: George Adams Date: Tue, 24 Mar 2026 15:10:53 +0000 Subject: [PATCH 3/4] temp apply CL 754080 --- go | 2 +- ...x-host-object-s-.pdata-entries-order.patch | 216 ++++++++++++++++++ 2 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 patches/0015-cmd-link-fix-host-object-s-.pdata-entries-order.patch diff --git a/go b/go index e30e65f7a8..0613d0309c 160000 --- a/go +++ b/go @@ -1 +1 @@ -Subproject commit e30e65f7a8bda0351d9def5a6bc91471bddafd3d +Subproject commit 0613d0309ce820ee651d7a0cf8e158c87fc6c444 diff --git a/patches/0015-cmd-link-fix-host-object-s-.pdata-entries-order.patch b/patches/0015-cmd-link-fix-host-object-s-.pdata-entries-order.patch new file mode 100644 index 0000000000..a0c89e8df5 --- /dev/null +++ b/patches/0015-cmd-link-fix-host-object-s-.pdata-entries-order.patch @@ -0,0 +1,216 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: bot-for-go[bot] <199222863+bot-for-go[bot]@users.noreply.github.com> +Date: Wed, 11 Mar 2026 13:14:41 +0100 +Subject: [PATCH] cmd/link: fix host object's .pdata entries order + +Host objects are expected to have their .pdata entries in the correct +order, but the Go internal linker might reorder some of the functions +associated with the .pdata entries. This causes the .pdata section +in the final binary to have entries in the wrong order, and therefore +issues with unwinding on Windows. + +The fix is to treat the .pdata entries of host objects as individual +symbols that will be retained only if the function they are associated +with is retained. Also, those entries will be sorted together with the +.pdata entries emitted by the Go compiler, ensuring the correct order +in the final binary. + +Fixes #65116 + +Change-Id: I421471b2aef519b0c20707a40c4b7957db5d2ed5 +--- + src/cmd/link/internal/ld/data.go | 14 ++++++ + src/cmd/link/internal/ld/lib.go | 4 +- + src/cmd/link/internal/loadpe/ldpe.go | 17 +++++-- + src/cmd/link/internal/loadpe/seh.go | 69 +++++++++++++++++++++------- + 4 files changed, 79 insertions(+), 25 deletions(-) + +diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go +index 1265b028e679fa..6ea55deebd8b16 100644 +--- a/src/cmd/link/internal/ld/data.go ++++ b/src/cmd/link/internal/ld/data.go +@@ -1689,6 +1689,20 @@ func (ctxt *Link) dodata(symGroupType []sym.SymKind) { + ldr.SetAttrOnList(s, true) + } + ++ // SEH symbols are tracked in side lists (sehp.pdata/xdata), so make ++ // them follow the same reachability decision used for all other data. ++ filterReachableSEH := func(syms []loader.Sym) []loader.Sym { ++ out := syms[:0] ++ for _, s := range syms { ++ if ldr.AttrReachable(s) { ++ out = append(out, s) ++ } ++ } ++ return out ++ } ++ sehp.pdata = filterReachableSEH(sehp.pdata) ++ sehp.xdata = filterReachableSEH(sehp.xdata) ++ + // Now that we have the data symbols, but before we start + // to assign addresses, record all the necessary + // dynamic relocations. These will grow the relocation +diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go +index 1c2b344abef7aa..77397383a79e88 100644 +--- a/src/cmd/link/internal/ld/lib.go ++++ b/src/cmd/link/internal/ld/lib.go +@@ -2411,9 +2411,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string, + if len(ls.Resources) != 0 { + setpersrc(ctxt, ls.Resources) + } +- if ls.PData != 0 { +- sehp.pdata = append(sehp.pdata, ls.PData) +- } ++ sehp.pdata = append(sehp.pdata, ls.PData...) + if ls.XData != 0 { + sehp.xdata = append(sehp.xdata, ls.XData) + } +diff --git a/src/cmd/link/internal/loadpe/ldpe.go b/src/cmd/link/internal/loadpe/ldpe.go +index 2073045c479a97..fe39fad429d1f8 100644 +--- a/src/cmd/link/internal/loadpe/ldpe.go ++++ b/src/cmd/link/internal/loadpe/ldpe.go +@@ -222,7 +222,7 @@ var comdatDefinitions map[string]int64 + type Symbols struct { + Textp []loader.Sym // text symbols + Resources []loader.Sym // .rsrc section or set of .rsrc$xx sections +- PData loader.Sym ++ PData []loader.Sym + XData loader.Sym + } + +@@ -256,7 +256,10 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read + defer f.Close() + state.f = f + +- var ls Symbols ++ var ( ++ ls Symbols ++ pdata loader.Sym ++ ) + + // TODO return error if found .cormeta + +@@ -312,7 +315,7 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read + ls.Resources = append(ls.Resources, s) + } else if bld.Type() == sym.SSEHSECT { + if sect.Name == ".pdata" { +- ls.PData = s ++ pdata = s + } else if sect.Name == ".xdata" { + ls.XData = s + } +@@ -596,8 +599,12 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read + } + } + +- if ls.PData != 0 { +- processSEH(l, arch, ls.PData, ls.XData) ++ if pdata != 0 { ++ subs, err := processSEH(l, arch, pdata) ++ if err != nil { ++ return nil, err ++ } ++ ls.PData = subs + } + + return &ls, nil +diff --git a/src/cmd/link/internal/loadpe/seh.go b/src/cmd/link/internal/loadpe/seh.go +index 545958f1d60bee..91d67c67fa7380 100644 +--- a/src/cmd/link/internal/loadpe/seh.go ++++ b/src/cmd/link/internal/loadpe/seh.go +@@ -21,24 +21,19 @@ const ( + unwCodeSize = 2 // Bytes per unwind code. + ) + +-// processSEH walks all pdata relocations looking for exception handler function symbols. +-// We want to mark these as reachable if the function that they protect is reachable +-// in the final binary. +-func processSEH(ldr *loader.Loader, arch *sys.Arch, pdata sym.LoaderSym, xdata sym.LoaderSym) error { ++// processSEH walks host-object pdata relocations and returns the set of ++// per-entry pdata symbols created from the input section. ++func processSEH(ldr *loader.Loader, arch *sys.Arch, pdata sym.LoaderSym) ([]loader.Sym, error) { + switch arch.Family { + case sys.AMD64: +- ldr.SetAttrReachable(pdata, true) +- if xdata != 0 { +- ldr.SetAttrReachable(xdata, true) +- } + return processSEHAMD64(ldr, pdata) + default: + // TODO: support SEH on other architectures. +- return fmt.Errorf("unsupported architecture for SEH: %v", arch.Family) ++ return nil, fmt.Errorf("unsupported architecture for SEH: %v", arch.Family) + } + } + +-func processSEHAMD64(ldr *loader.Loader, pdata sym.LoaderSym) error { ++func processSEHAMD64(ldr *loader.Loader, pdata sym.LoaderSym) ([]loader.Sym, error) { + // The following loop traverses a list of pdata entries, + // each entry being 3 relocations long. The first relocation + // is a pointer to the function symbol to which the pdata entry +@@ -48,18 +43,58 @@ func processSEHAMD64(ldr *loader.Loader, pdata sym.LoaderSym) error { + // https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-runtime_function + rels := ldr.Relocs(pdata) + if rels.Count()%3 != 0 { +- return fmt.Errorf(".pdata symbol %q has invalid relocation count", ldr.SymName(pdata)) ++ return nil, fmt.Errorf(".pdata symbol %q has invalid relocation count", ldr.SymName(pdata)) + } ++ data := ldr.Data(pdata) ++ entries := make([]loader.Sym, 0, rels.Count()/3) ++ + for i := 0; i < rels.Count(); i += 3 { +- xrel := rels.At(i + 2) +- handler := findHandlerInXDataAMD64(ldr, xrel.Sym(), xrel.Add()) +- if handler != 0 { +- sb := ldr.MakeSymbolUpdater(rels.At(i).Sym()) ++ // Create a new symbol for the pdata entry. ++ entry := ldr.MakeSymbolBuilder("") ++ entry.SetType(sym.SSEHSECT) ++ entry.SetAlign(4) ++ entry.SetSize(12) ++ entryOff := int(rels.At(i).Off()) ++ entryEnd := entryOff + 4*3 ++ entry.SetData(data[entryOff:entryEnd:entryEnd]) ++ ++ // Add a relocation from the target function to the pdata entry ++ // and to the exception handler, if present, to ensure they are ++ // retained by dead code elimination. ++ if targetFunc := rels.At(i).Sym(); targetFunc != 0 { ++ sb := ldr.MakeSymbolUpdater(targetFunc) + r, _ := sb.AddRel(objabi.R_KEEP) +- r.SetSym(handler) ++ r.SetSym(entry.Sym()) ++ xrel := rels.At(i + 2) ++ if xrel.Sym() != 0 { ++ r, _ = sb.AddRel(objabi.R_KEEP) ++ r.SetSym(xrel.Sym()) ++ } ++ handler := findHandlerInXDataAMD64(ldr, xrel.Sym(), xrel.Add()) ++ if handler != 0 { ++ r, _ = sb.AddRel(objabi.R_KEEP) ++ r.SetSym(handler) ++ } + } ++ ++ // Copy the relocations from the original .pdata entry to the new symbol, ++ // adjusting the offsets. ++ for j := range 3 { ++ rOld := rels.At(i + j) ++ typ := rOld.Type() ++ if rOld.Weak() { ++ typ |= objabi.R_WEAK ++ } ++ rel, _ := entry.AddRel(typ) ++ rel.SetOff(int32(j * 4)) ++ rel.SetSiz(rOld.Siz()) ++ rel.SetSym(rOld.Sym()) ++ rel.SetAdd(rOld.Add()) ++ } ++ ++ entries = append(entries, entry.Sym()) + } +- return nil ++ return entries, nil + } + + // findHandlerInXDataAMD64 finds the symbol in the .xdata section that From 88c86408b5c1d1cba92bab22c5f3e27158f88904 Mon Sep 17 00:00:00 2001 From: George Adams Date: Tue, 24 Mar 2026 15:16:40 +0000 Subject: [PATCH 4/4] resolve 3-way merge conflicts --- .../0001-Vendor-external-dependencies.patch | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/patches/0001-Vendor-external-dependencies.patch b/patches/0001-Vendor-external-dependencies.patch index c76de32cb4..cda58da7a1 100644 --- a/patches/0001-Vendor-external-dependencies.patch +++ b/patches/0001-Vendor-external-dependencies.patch @@ -553,7 +553,7 @@ Use a 'go' that was recently built by the current branch to ensure stable result create mode 100644 src/vendor/github.com/microsoft/go-crypto-winnative/internal/sysdll/sys_windows.go diff --git a/src/cmd/go.mod b/src/cmd/go.mod -index 3bc983397186a6..6556bfdbe3f0a4 100644 +index d15db1306b8e0b..f726601843bdaa 100644 --- a/src/cmd/go.mod +++ b/src/cmd/go.mod @@ -4,6 +4,8 @@ go 1.27 @@ -564,9 +564,9 @@ index 3bc983397186a6..6556bfdbe3f0a4 100644 + github.com/microsoft/go-infra/telemetry/config v0.0.0-20260128082012-a1498e2b57dd golang.org/x/arch v0.23.1-0.20260109160903-657d90bd6695 golang.org/x/build v0.0.0-20260122183339-3ba88df37c64 - golang.org/x/mod v0.32.0 + golang.org/x/mod v0.34.0 diff --git a/src/cmd/go.sum b/src/cmd/go.sum -index 224585feb6332d..ebf6a4c11e165e 100644 +index 23627773f00451..5ac25412c24ac4 100644 --- a/src/cmd/go.sum +++ b/src/cmd/go.sum @@ -4,6 +4,10 @@ github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/v @@ -2175,7 +2175,7 @@ index 00000000000000..d592037b570130 + return ok +} diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt -index ceed574b32b507..e29e38f7da3cb3 100644 +index 7b5b9aa37f749c..c2b79ea9ca5213 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt @@ -16,6 +16,17 @@ github.com/google/pprof/third_party/svgpan @@ -2225,11 +2225,11 @@ index 00000000000000..ae4055d2d71303 +// that are used by the backend package. This allows to track +// their versions in a single patch file. diff --git a/src/go.mod b/src/go.mod -index d6c515017a7009..348650059a4497 100644 +index 2ac54d7b35e011..043e7ea6bbe4a8 100644 --- a/src/go.mod +++ b/src/go.mod @@ -11,3 +11,9 @@ require ( - golang.org/x/sys v0.40.1-0.20260116220947-d25a7aaff8c2 // indirect + golang.org/x/sys v0.42.1-0.20260320201212-a76ec62d6c53 // indirect golang.org/x/text v0.33.1-0.20260122225119-3264de9174be // indirect ) + @@ -2239,7 +2239,7 @@ index d6c515017a7009..348650059a4497 100644 + github.com/microsoft/go-crypto-winnative v0.0.0-20260224091131-eabf5d4ea9cb +) diff --git a/src/go.sum b/src/go.sum -index 2223d2a7c231c1..55a77ae199a9af 100644 +index ba6fd0576632d4..40a76b70d3cc2d 100644 --- a/src/go.sum +++ b/src/go.sum @@ -1,3 +1,9 @@ @@ -2253,7 +2253,7 @@ index 2223d2a7c231c1..55a77ae199a9af 100644 golang.org/x/crypto v0.47.1-0.20260113154411-7d0074ccc6f1/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= golang.org/x/net v0.49.1-0.20260122225915-f2078620ee33 h1:pNHjOZ0w6qb8R9EDmEsBXmV4o2YKLvtRiEk4q5gN5Hg= diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go -index 863882aebf583e..a0436aa1901b7e 100644 +index be424e1b16c8d0..722b21661f29a8 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -154,6 +154,13 @@ var depsRules = ` @@ -2333,7 +2333,7 @@ index 863882aebf583e..a0436aa1901b7e 100644 CRYPTO, FMT, math/big, internal/saferio < crypto/internal/boring/bbig < crypto/internal/fips140cache -@@ -924,7 +965,7 @@ var buildIgnore = []byte("\n//go:build ignore") +@@ -928,7 +969,7 @@ var buildIgnore = []byte("\n//go:build ignore") func findImports(pkg string) ([]string, error) { vpkg := pkg @@ -2342,7 +2342,7 @@ index 863882aebf583e..a0436aa1901b7e 100644 vpkg = "vendor/" + pkg } dir := filepath.Join(Default.GOROOT, "src", vpkg) -@@ -934,7 +975,7 @@ func findImports(pkg string) ([]string, error) { +@@ -938,7 +979,7 @@ func findImports(pkg string) ([]string, error) { } var imports []string var haveImport = map[string]bool{} @@ -38655,7 +38655,7 @@ index 00000000000000..1722410e5af193 + return getSystemDirectory() + "\\" + dll +} diff --git a/src/vendor/modules.txt b/src/vendor/modules.txt -index 48967bc9ee3bd2..b4491a043c1f3f 100644 +index e8c6f1efb099eb..ad1216357d8cb2 100644 --- a/src/vendor/modules.txt +++ b/src/vendor/modules.txt @@ -1,3 +1,26 @@