]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: use correct length for pcln.cutab
authorIan Lance Taylor <iant@golang.org>
Mon, 29 Sep 2025 04:25:24 +0000 (21:25 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 29 Sep 2025 17:06:19 +0000 (10:06 -0700)
The pcln.cutab slice holds uint32 elements, as can be seen in the
runtime.moduledata type. The slice was being created with the len
(and cap) set to the size of the slice, which means that the count
was four times too large. This patch sets the correct len/cap.

This doesn't matter for the runtime because nothing looks at
the len of cutab. Since the incorrect len is larger, all valid
indexes remain valid. Using the correct length means that more
invalid indexes will be caught at run time, but such cases are unlikely.
Still, using the correct len is less confusing.

While we're here use the simpler sliceSym for pcln.pclntab.

Change-Id: I09f680b3287467120d994b171c86c784085e3d27
Reviewed-on: https://go-review.googlesource.com/c/go/+/707595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

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

index 759262286d39d80ede00c7a21585eaef91dd7955..2c999ccc4e3a198e3047bcc2eaadee943758da7b 100644 (file)
@@ -645,7 +645,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
        sliceSym(pcln.funcnametab)
 
        // The cutab slice
-       sliceSym(pcln.cutab)
+       slice(pcln.cutab, uint64(ldr.SymSize(pcln.cutab))/4)
 
        // The filetab slice
        sliceSym(pcln.filetab)
@@ -654,7 +654,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
        sliceSym(pcln.pctab)
 
        // The pclntab slice
-       slice(pcln.pclntab, uint64(ldr.SymSize(pcln.pclntab)))
+       sliceSym(pcln.pclntab)
 
        // The ftab slice
        slice(pcln.pclntab, uint64(pcln.nfunc+1))