mirror of
https://github.com/golang/go
synced 2024-11-02 08:01:26 +00:00
cmd/link: resolve ABI alias for runtime.unreachableMethod
We redirect references to unreachable methods to runtime.unreachableMethod. We choose to use ABIInternal symbol for this, because runtime.unreachableMethod is a defined Go function. When linking against shared libraries, and ABI wrappers are not enabled, the imported function symbols are all ABI0 and aliased to ABIInternal. We need to resolve ABI alias in this case. Change-Id: Idd64ef46ce0b5f54882ea0069ce0d59dc9b7a599 Reviewed-on: https://go-review.googlesource.com/c/go/+/319891 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
7a7624a3fa
commit
92c189f211
1 changed files with 2 additions and 0 deletions
|
@ -340,6 +340,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
|
||||||
if weak && !ldr.AttrReachable(rs) {
|
if weak && !ldr.AttrReachable(rs) {
|
||||||
// Redirect it to runtime.unreachableMethod, which will throw if called.
|
// Redirect it to runtime.unreachableMethod, which will throw if called.
|
||||||
rs = syms.unreachableMethod
|
rs = syms.unreachableMethod
|
||||||
|
rs = ldr.ResolveABIAlias(rs)
|
||||||
}
|
}
|
||||||
if target.IsExternal() {
|
if target.IsExternal() {
|
||||||
nExtReloc++
|
nExtReloc++
|
||||||
|
@ -623,6 +624,7 @@ func extreloc(ctxt *Link, ldr *loader.Loader, s loader.Sym, r loader.Reloc) (loa
|
||||||
rs := ldr.ResolveABIAlias(r.Sym())
|
rs := ldr.ResolveABIAlias(r.Sym())
|
||||||
if r.Weak() && !ldr.AttrReachable(rs) {
|
if r.Weak() && !ldr.AttrReachable(rs) {
|
||||||
rs = ctxt.ArchSyms.unreachableMethod
|
rs = ctxt.ArchSyms.unreachableMethod
|
||||||
|
rs = ldr.ResolveABIAlias(rs)
|
||||||
}
|
}
|
||||||
rs, off := FoldSubSymbolOffset(ldr, rs)
|
rs, off := FoldSubSymbolOffset(ldr, rs)
|
||||||
rr.Xadd = r.Add() + off
|
rr.Xadd = r.Add() + off
|
||||||
|
|
Loading…
Reference in a new issue