]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.link] cmd/link: fix payload pointer liveness
authorCherry Zhang <cherryyz@google.com>
Thu, 30 Jan 2020 03:10:51 +0000 (22:10 -0500)
committerCherry Zhang <cherryyz@google.com>
Fri, 31 Jan 2020 17:41:52 +0000 (17:41 +0000)
commitb1f9f479820be1c251cbdcadfdf9c94d7f6c2e72
tree8c761c4b9b1a00aebf2b4f9603cebd1f4b885a75
parentaf98efc545476cea052881e0a6e623f7219d5e97
[dev.link] cmd/link: fix payload pointer liveness

Currently, the symbol updater uses a pointer pointing to the
loader's payloads array. If the payloads slice grows (and moves),
the pointer may become stale and no longer point to the symbol's
actual payload. Specifically, consider

sb, sym := l.MakeSymbolUpdater(...)
// add a bunch of external symbols, which grows payload slice
sb.SetType(t)
l.SymType(sym) // may not return t

sb.SetType on line 3 may not have the desired effect, as
sb.extSymPayload may no longer point to the right payload. As a
result, the type we get on line 4 may be not the one we set.

Fix this by making the payload's address permanent. Once it is
allocated it will never move.

Change-Id: Iab190ea5aceb5c37f91d09ad4ffd458e881b03f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/217063
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/loader/loader_test.go
src/cmd/link/internal/loader/symbolbuilder.go