]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: fold zero symbol check into ResolveABIAlias
authorCherry Zhang <cherryyz@google.com>
Thu, 30 Apr 2020 05:39:18 +0000 (01:39 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 30 Apr 2020 15:53:49 +0000 (15:53 +0000)
We call (or will call) ResolveABIAlias in many places. Doing zero
symbol check everytime is annoying. Fold the condition into
ResolveABIAlias.

Change-Id: I10485fe83b9cce2d19b6bd17dc42176f72dae48b
Reviewed-on: https://go-review.googlesource.com/c/go/+/231046
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/loader/loader.go

index 4852a18049de9d6b64acddbd7cd18293dde5660f..84b5b494b2659e4fc6bd41ea99e447a0487a864d 100644 (file)
@@ -161,9 +161,7 @@ func relocsym(target *Target, ldr *loader.Loader, err *ErrorReporter, syms *Arch
                off := r.Off()
                siz := int32(r.Siz())
                rs := r.Sym()
-               if rs != 0 {
-                       rs = ldr.ResolveABIAlias(rs)
-               }
+               rs = ldr.ResolveABIAlias(rs)
                rt := r.Type()
                if off < 0 || off+siz > int32(len(P)) {
                        rname := ""
index 7736ba97715f5ef247daf3c3fe324d45614e4c2c..a7b65e3580e478f0d362262efb8fd47b5fc40cd7 100644 (file)
@@ -2161,6 +2161,9 @@ func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols, needReloc bool) {
 // symbol. If the sym in question is not an alias, the sym itself is
 // returned.
 func (l *Loader) ResolveABIAlias(s Sym) Sym {
+       if s == 0 {
+               return 0
+       }
        if l.SymType(s) != sym.SABIALIAS {
                return s
        }