From: Cherry Zhang Date: Mon, 1 Feb 2021 21:46:49 +0000 (-0500) Subject: cmd/link: fix off-by-1 error in findShlibSection X-Git-Tag: go1.16~1^2~31 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1426a571b79bfcb3c0339e2fd96c893cd1549af6;p=gostls13.git cmd/link: fix off-by-1 error in findShlibSection We want to find a section that contains addr. sect.Addr+sect.Size is the exclusive upper bound. Change-Id: If2cd6bdd6e03174680e066189b0f4bf9e2ba6630 Reviewed-on: https://go-review.googlesource.com/c/go/+/288592 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/ld/decodesym.go b/src/cmd/link/internal/ld/decodesym.go index c6e2d8ca7f..fc179fc6e4 100644 --- a/src/cmd/link/internal/ld/decodesym.go +++ b/src/cmd/link/internal/ld/decodesym.go @@ -279,7 +279,7 @@ func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section { for _, shlib := range ctxt.Shlibs { if shlib.Path == path { for _, sect := range shlib.File.Sections[1:] { // skip the NULL section - if sect.Addr <= addr && addr <= sect.Addr+sect.Size { + if sect.Addr <= addr && addr < sect.Addr+sect.Size { return sect } }