cmd/internal/ld: handle TLS and imported symbols more regularly

For shared libraries we need to be more flexible in how these symbols
are handled (e.g. sometimes tlsg needs to be global, or you can get
a SDYNIMPORT symbol that has .Hide == true) so handling these cases
in genasmsym makes everything much more regular.

Even ignoring shared libraries, I think this is a bit cleaner.

Change-Id: If5beb093a261e79f4496183226e1765ee7aa6717
Reviewed-on: https://go-review.googlesource.com/8230
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2015-03-29 21:03:05 +00:00 committed by Ian Lance Taylor
parent 00e0fe4b95
commit b8417854c3
2 changed files with 41 additions and 52 deletions

View file

@ -430,7 +430,6 @@ func loadlib() {
tlsg.Type = STLSBSS
}
tlsg.Size = int64(Thearch.Ptrsize)
tlsg.Hide = 1
tlsg.Reachable = true
Ctxt.Tlsg = tlsg
@ -1375,7 +1374,6 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
continue
}
put(s, s.Name, 'D', Symaddr(s), s.Size, int(s.Version), s.Gotype)
continue
case SBSS,
SNOPTRBSS:
@ -1386,18 +1384,31 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
Diag("%s should not be bss (size=%d type=%d special=%d)", s.Name, int(len(s.P)), s.Type, s.Special)
}
put(s, s.Name, 'B', Symaddr(s), s.Size, int(s.Version), s.Gotype)
continue
case SFILE:
put(nil, s.Name, 'f', s.Value, 0, int(s.Version), nil)
continue
case SHOSTOBJ:
if HEADTYPE == Hwindows {
if HEADTYPE == Hwindows || Iself {
put(s, s.Name, 'U', s.Value, 0, int(s.Version), nil)
}
continue
case SDYNIMPORT:
if !s.Reachable {
continue
}
put(s, s.Extname, 'U', 0, 0, int(s.Version), nil)
case STLSBSS:
if Linkmode == LinkExternal && HEADTYPE != Hopenbsd {
var type_ int
if goos == "android" {
type_ = 'B'
} else {
type_ = 't'
}
put(s, s.Name, type_, Symaddr(s), s.Size, int(s.Version), s.Gotype)
}
}
}