mirror of
https://github.com/golang/go.git
synced 2025-05-30 19:52:53 +00:00
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
de4317cbd7
commit
2ac8555d57
@ -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.Type = obj.SRODATA
|
||||||
s.Attr |= AttrLocal
|
s.Attr |= AttrLocal
|
||||||
Adduint32(ctxt, s, uint32(i32))
|
switch s.Name[:5] {
|
||||||
s.Attr.Set(AttrReachable, false)
|
case "$f32.":
|
||||||
} else if strings.HasPrefix(s.Name, "$f64.") || strings.HasPrefix(s.Name, "$i64.") {
|
if uint64(uint32(x)) != x {
|
||||||
x, _ := strconv.ParseUint(s.Name[5:], 16, 64)
|
log.Panicf("$-symbol %s too large: %d", s.Name, x)
|
||||||
i64 := int64(x)
|
}
|
||||||
s.Type = obj.SRODATA
|
Adduint32(ctxt, s, uint32(x))
|
||||||
s.Attr |= AttrLocal
|
case "$f64.", "$i64.":
|
||||||
Adduint64(ctxt, s, uint64(i64))
|
Adduint64(ctxt, s, x)
|
||||||
|
default:
|
||||||
|
log.Panicf("unrecognized $-symbol: %s", s.Name)
|
||||||
|
}
|
||||||
s.Attr.Set(AttrReachable, false)
|
s.Attr.Set(AttrReachable, false)
|
||||||
}
|
}
|
||||||
}
|
if strings.HasPrefix(s.Name, "runtime.gcbits.") {
|
||||||
if v == 0 && strings.HasPrefix(s.Name, "runtime.gcbits.") {
|
|
||||||
s.Attr |= AttrLocal
|
s.Attr |= AttrLocal
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user