Skip to content

Commit ae8eba0

Browse files
ianlancetaylorgopherbot
authored andcommitted
cmd/link: use correct length for pcln.cutab
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 <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent fe3ba74 commit ae8eba0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
645645
sliceSym(pcln.funcnametab)
646646

647647
// The cutab slice
648-
sliceSym(pcln.cutab)
648+
slice(pcln.cutab, uint64(ldr.SymSize(pcln.cutab))/4)
649649

650650
// The filetab slice
651651
sliceSym(pcln.filetab)
@@ -654,7 +654,7 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
654654
sliceSym(pcln.pctab)
655655

656656
// The pclntab slice
657-
slice(pcln.pclntab, uint64(ldr.SymSize(pcln.pclntab)))
657+
sliceSym(pcln.pclntab)
658658

659659
// The ftab slice
660660
slice(pcln.pclntab, uint64(pcln.nfunc+1))

0 commit comments

Comments
 (0)