cmd/link: always mark runtime.unreachableMethod symbol

In the deadcode path we mark runtime.unreachableMethod symbol,
which is a special symbol used for redirecting unreachable
methods. Currently this code is conditioned on not -linkshared.
This is wrong. It should be marked with -linkshared mode as well.

In fact, -linkshared should only affect the entry symbol. Change
the code accordingly.

Change-Id: I252abf850212a930f275589ef0035a43e52cb9cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/319893
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Mui 2021-05-13 16:48:50 -04:00
parent 92c189f211
commit b4833f7c06

View file

@ -65,6 +65,7 @@ func (d *deadcodePass) init() {
} }
} }
names = append(names, *flagEntrySymbol) names = append(names, *flagEntrySymbol)
}
// runtime.unreachableMethod is a function that will throw if called. // runtime.unreachableMethod is a function that will throw if called.
// We redirect unreachable methods to it. // We redirect unreachable methods to it.
names = append(names, "runtime.unreachableMethod") names = append(names, "runtime.unreachableMethod")
@ -87,7 +88,6 @@ func (d *deadcodePass) init() {
} }
} }
} }
}
if d.ctxt.Debugvlog > 1 { if d.ctxt.Debugvlog > 1 {
d.ctxt.Logf("deadcode start names: %v\n", names) d.ctxt.Logf("deadcode start names: %v\n", names)