mirror of https://github.com/golang/go.git
cmd/link: mangle symbol ABI name for linker-generated symbols
The ABI mangling code skips symbols that are not loaded from Go objects. Usually that is fine, as other symbols don't need name mangling. But trampolines are linker generated and have the same symbol version (ABI) as the underlying symbol. We need to avoid symbol name collisions for trampolines, such as a trampoline to f<ABI0> and a trampoline to f<ABIInternal>. We could explicitly incorportate the ABI into the trampoline name. But as we already have the name mangling scheme we could just use that. The original code excludes external symbols probably because symbols from C object don't need mangling. But a C symbol and a Go symbol shouldn't have same name, and so the condition won't apply. Also exclude static symbols as they don't need mangling. Change-Id: I298eb1d64bc0c3da0154f0146b95c4d26ca2f47a Reviewed-on: https://go-review.googlesource.com/c/go/+/399894 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
1f97f960e7
commit
9c7f0b1ccd
|
|
@ -857,7 +857,7 @@ func mangleABIName(ctxt *Link, ldr *loader.Loader, x loader.Sym, name string) st
|
|||
return name
|
||||
}
|
||||
|
||||
if !ldr.IsExternal(x) && ldr.SymType(x) == sym.STEXT && ldr.SymVersion(x) != sym.SymVerABIInternal {
|
||||
if ldr.SymType(x) == sym.STEXT && ldr.SymVersion(x) != sym.SymVerABIInternal && ldr.SymVersion(x) < sym.SymVerStatic {
|
||||
if s2 := ldr.Lookup(name, sym.SymVerABIInternal); s2 != 0 && ldr.SymType(s2) == sym.STEXT {
|
||||
name = fmt.Sprintf("%s.abi%d", name, ldr.SymVersion(x))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue