From: David Crawshaw Date: Fri, 13 Oct 2017 16:41:09 +0000 (-0400) Subject: cmd/link: zero symtab fields correctly X-Git-Tag: go1.10beta1~726 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=350b74bc4b9f37ba29ef02c2f89d687ae8563a05;p=gostls13.git cmd/link: zero symtab fields correctly CL 69370 introduced a hasmain field to moduledata after the modulehashes slice. However that code was relying on the zeroing code after it to cover modulehashes if len(Shlibs) == 0. The hasmain field gets in the way of that. So clear modulehashes explicitly in that case. Found when looking at #22250. Not sure if it's related. Change-Id: I81050cb4554cd49e9f245d261ef422f97d026df4 Reviewed-on: https://go-review.googlesource.com/70730 Run-TryBot: David Crawshaw TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index c77298e870..5adce1530b 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -639,6 +639,12 @@ func (ctxt *Link) symtab() { moduledata.AddAddr(ctxt.Arch, modulehashes) moduledata.AddUint(ctxt.Arch, uint64(len(ctxt.Shlibs))) moduledata.AddUint(ctxt.Arch, uint64(len(ctxt.Shlibs))) + } else { + moduledata.AddUint(ctxt.Arch, 0) // modulename + moduledata.AddUint(ctxt.Arch, 0) + moduledata.AddUint(ctxt.Arch, 0) // moduleshashes slice + moduledata.AddUint(ctxt.Arch, 0) + moduledata.AddUint(ctxt.Arch, 0) } hasmain := ctxt.BuildMode == BuildModeExe || ctxt.BuildMode == BuildModePIE