1
0
mirror of https://github.com/golang/go synced 2024-11-23 23:00:03 -07:00

[dev.link] cmd/link: fold zero symbol check into ResolveABIAlias

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>
This commit is contained in:
Cherry Zhang 2020-04-30 01:39:18 -04:00
parent 516c29a79f
commit 2a00c137b1
2 changed files with 4 additions and 3 deletions

View 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 := ""

View 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
}