From 1426a571b79bfcb3c0339e2fd96c893cd1549af6 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Mon, 1 Feb 2021 16:46:49 -0500 Subject: 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 --- src/cmd/link/internal/ld/decodesym.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } } -- cgit v1.2.3-54-g00ecf