Skip to content

Commit 350b74b

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 0e4de78 commit 350b74b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/cmd/link/internal/ld/symtab.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,12 @@ func (ctxt *Link) symtab() {
639639
moduledata.AddAddr(ctxt.Arch, modulehashes)
640640
moduledata.AddUint(ctxt.Arch, uint64(len(ctxt.Shlibs)))
641641
moduledata.AddUint(ctxt.Arch, uint64(len(ctxt.Shlibs)))
642+
} else {
643+
moduledata.AddUint(ctxt.Arch, 0) // modulename
644+
moduledata.AddUint(ctxt.Arch, 0)
645+
moduledata.AddUint(ctxt.Arch, 0) // moduleshashes slice
646+
moduledata.AddUint(ctxt.Arch, 0)
647+
moduledata.AddUint(ctxt.Arch, 0)
642648
}
643649

644650
hasmain := ctxt.BuildMode == BuildModeExe || ctxt.BuildMode == BuildModePIE

0 commit comments

Comments
 (0)