1
0
mirror of https://github.com/golang/go synced 2024-11-26 01:17:57 -07:00

[dev.regabi] cmd/link: stop using ABI aliases if wrapper is enabled

If ABI wrappers are enabled, we should not see ABI aliases at
link time. Stop resolving them. One exception is shared linkage,
where we still use ABI aliases as we don't always know the ABI
for symbols from shared libraries.

Change-Id: Ia89a788094382adeb4c4ef9b0312aa6e8c2f79ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/290032
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Cherry Zhang 2021-02-05 18:07:46 -05:00
parent 168d6a49a5
commit 59703d53e2
2 changed files with 11 additions and 1 deletions

View File

@ -489,10 +489,16 @@ func (ctxt *Link) loadlib() {
case 0:
// nothing to do
case 1, 2:
flags = loader.FlagStrictDups
flags |= loader.FlagStrictDups
default:
log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups)
}
if !*flagAbiWrap || ctxt.linkShared {
// Use ABI aliases if ABI wrappers are not used.
// TODO: for now we still use ABI aliases in shared linkage, even if
// the wrapper is enabled.
flags |= loader.FlagUseABIAlias
}
elfsetstring1 := func(str string, off int) { elfsetstring(ctxt, 0, str, off) }
ctxt.loader = loader.NewLoader(flags, elfsetstring1, &ctxt.ErrorReporter.ErrorReporter)
ctxt.ErrorReporter.SymName = func(s loader.Sym) string {

View File

@ -322,6 +322,7 @@ type extSymPayload struct {
const (
// Loader.flags
FlagStrictDups = 1 << iota
FlagUseABIAlias
)
func NewLoader(flags uint32, elfsetstring elfsetstringFunc, reporter *ErrorReporter) *Loader {
@ -2270,6 +2271,9 @@ func abiToVer(abi uint16, localSymVersion int) int {
// symbol. If the sym in question is not an alias, the sym itself is
// returned.
func (l *Loader) ResolveABIAlias(s Sym) Sym {
if l.flags&FlagUseABIAlias == 0 {
return s
}
if s == 0 {
return 0
}