]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/link: stop using ABI aliases if wrapper is enabled
authorCherry Zhang <cherryyz@google.com>
Fri, 5 Feb 2021 23:07:46 +0000 (18:07 -0500)
committerCherry Zhang <cherryyz@google.com>
Wed, 10 Feb 2021 15:40:37 +0000 (15:40 +0000)
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>

src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/loader/loader.go

index 71cef0b774ff8d4a2bcda88f4b692ae2f57be29d..314896824a03fcb8d3dcb58146759d10adbeb615 100644 (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 {
index 971cc432ff54b10921202e6a96df60494131a039..98c2131c2b43f1106f9d19e547ac62ac87914acf 100644 (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
        }