From 5cc1e99f94be59a65ba291e06af6afec7a978427 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Tue, 12 Sep 2023 13:52:42 -0400 Subject: [PATCH] runtime: fix off-by-1 error in textOff The code meant to check if it is the last section, which is i === len(md.textsectmap)-1. The -1 was missing. Change-Id: Ifbb9e40df730abe3bec20fde5f56f5c75dfd9e8f Reviewed-on: https://go-review.googlesource.com/c/go/+/527795 LUCI-TryBot-Result: Go LUCI Reviewed-by: Than McIntosh --- src/runtime/symtab.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 129af01a34..0cc3085f6a 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -622,7 +622,7 @@ func (md *moduledata) textOff(pc uintptr) (uint32, bool) { } end := sect.baseaddr + (sect.end - sect.vaddr) // For the last section, include the end address (etext), as it is included in the functab. - if i == len(md.textsectmap) { + if i == len(md.textsectmap)-1 { end++ } if pc < end { -- 2.50.0