]> Cypherpunks repositories - gostls13.git/commit
cmd/link, runtime: use a sentinel value for unreachable method
authorCherry Zhang <cherryyz@google.com>
Thu, 24 Sep 2020 20:54:31 +0000 (16:54 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 29 Sep 2020 15:20:13 +0000 (15:20 +0000)
commit0ab72ed020d0c320b5007987abdf40677db34cfc
treeadfacfc78e174b0aa3e477a191b7b956a5b6f26f
parent0163bdae685c1b060f8108ac5af13ea6374555b1
cmd/link, runtime: use a sentinel value for unreachable method

In the method table, the method's code pointer is stored as an
offset from the start of the text section. Currently, for an
unreachable method, the offset is left as 0, which resolves to
the start of the text section at run time. It is possible that
there is valid code there. If an unreachable method is ever
reached (due to a compiler or linker bug), the execution will
jump to a wrong location but may continue to run for a while,
until it fails with a seemingly unrelated error.

This CL changes it to use -1 for unreachable method instead. At
run time this will resolve to an invalid address, which makes it
fail immediately if it is ever reached.

Change-Id: Ied6ed7f1833c4f3b991fdf55d8810d70d307b2e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/257203
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/data.go
src/runtime/type.go