From cf125a36d50397b1a1821304a33fd6fa7e3cf4cd Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 27 Oct 2015 14:49:51 +1300 Subject: [PATCH] cmd/link: fix size of filetab slice The linker writes the number of file symbols (Nhistfile) to the filetab slice and then Nhistfile offsets -- which means the slice contains Nhistfile+1 entries, not just Nhistfile. I think this bug has been around since at least 1.4 but it's easier to trigger with shared libraries and a tiny binary that only has a couple of functions in it -- try go install -buildmode=shared std && go run -linkshared test/fixedbugs/issue4388.go. Change-Id: I6c0f01f1e607b9b2b96872e37ffce81281911504 Reviewed-on: https://go-review.googlesource.com/16342 Run-TryBot: Michael Hudson-Doyle TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/cmd/link/internal/ld/symtab.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index 005e876d28..646968f584 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -498,8 +498,8 @@ func symtab() { adduint(Ctxt, moduledata, uint64(pclntabNfunc+1)) // The filetab slice Addaddrplus(Ctxt, moduledata, Linklookup(Ctxt, "runtime.pclntab", 0), int64(pclntabFiletabOffset)) - adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)) - adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)) + adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)+1) + adduint(Ctxt, moduledata, uint64(Ctxt.Nhistfile)+1) // findfunctab Addaddr(Ctxt, moduledata, Linklookup(Ctxt, "runtime.findfunctab", 0)) // minpc, maxpc -- 2.48.1