Commit 2ac8555d authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/link: tidy up rdsym

Use an early return. Check errors. Deduplicate.

Change-Id: Iabefd563b5ef82a16fab4791277630804fd09003
Reviewed-on: https://go-review.googlesource.com/20597
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent de4317cb
...@@ -494,25 +494,31 @@ func rdsym(ctxt *Link, f *obj.Biobuf, pkg string) *LSym { ...@@ -494,25 +494,31 @@ func rdsym(ctxt *Link, f *obj.Biobuf, pkg string) *LSym {
v = ctxt.Version v = ctxt.Version
} }
s := Linklookup(ctxt, name, v) s := Linklookup(ctxt, name, v)
if v != 0 {
return s
}
if v == 0 && s.Name[0] == '$' && s.Type == 0 { if s.Name[0] == '$' && len(s.Name) > 5 && s.Type == 0 {
if strings.HasPrefix(s.Name, "$f32.") { x, err := strconv.ParseUint(s.Name[5:], 16, 64)
x, _ := strconv.ParseUint(s.Name[5:], 16, 32) if err != nil {
i32 := int32(x) log.Panicf("failed to parse $-symbol %s: %v", s.Name, err)
s.Type = obj.SRODATA }
s.Attr |= AttrLocal s.Type = obj.SRODATA
Adduint32(ctxt, s, uint32(i32)) s.Attr |= AttrLocal
s.Attr.Set(AttrReachable, false) switch s.Name[:5] {
} else if strings.HasPrefix(s.Name, "$f64.") || strings.HasPrefix(s.Name, "$i64.") { case "$f32.":
x, _ := strconv.ParseUint(s.Name[5:], 16, 64) if uint64(uint32(x)) != x {
i64 := int64(x) log.Panicf("$-symbol %s too large: %d", s.Name, x)
s.Type = obj.SRODATA }
s.Attr |= AttrLocal Adduint32(ctxt, s, uint32(x))
Adduint64(ctxt, s, uint64(i64)) case "$f64.", "$i64.":
s.Attr.Set(AttrReachable, false) Adduint64(ctxt, s, x)
default:
log.Panicf("unrecognized $-symbol: %s", s.Name)
} }
s.Attr.Set(AttrReachable, false)
} }
if v == 0 && strings.HasPrefix(s.Name, "runtime.gcbits.") { if strings.HasPrefix(s.Name, "runtime.gcbits.") {
s.Attr |= AttrLocal s.Attr |= AttrLocal
} }
return s return s
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment