mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: pack LSym boolean attributes
No performance improvement, but possibly more readable. Linking juju: tip: real 0m5.470s user 0m6.131s this: real 0m5.392s user 0m6.087s Change-Id: I578e94fbe6c11b19d79034c33b3db31d9689d439 Reviewed-on: https://go-review.googlesource.com/20108 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
d7cdf66978
commit
a3c258a567
20 changed files with 283 additions and 253 deletions
|
|
@ -63,7 +63,7 @@ func setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
if s.Size < off+wid {
|
||||
s.Size = off + wid
|
||||
Symgrow(ctxt, s, s.Size)
|
||||
|
|
@ -121,7 +121,7 @@ func Addaddrplus(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
i := s.Size
|
||||
s.Size += int64(ctxt.Arch.Ptrsize)
|
||||
Symgrow(ctxt, s, s.Size)
|
||||
|
|
@ -138,7 +138,7 @@ func Addpcrelplus(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
i := s.Size
|
||||
s.Size += 4
|
||||
Symgrow(ctxt, s, s.Size)
|
||||
|
|
@ -159,7 +159,7 @@ func setaddrplus(ctxt *Link, s *LSym, off int64, t *LSym, add int64) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
if off+int64(ctxt.Arch.Ptrsize) > s.Size {
|
||||
s.Size = off + int64(ctxt.Arch.Ptrsize)
|
||||
Symgrow(ctxt, s, s.Size)
|
||||
|
|
@ -182,7 +182,7 @@ func addsize(ctxt *Link, s *LSym, t *LSym) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
i := s.Size
|
||||
s.Size += int64(ctxt.Arch.Ptrsize)
|
||||
Symgrow(ctxt, s, s.Size)
|
||||
|
|
@ -198,7 +198,7 @@ func addaddrplus4(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
i := s.Size
|
||||
s.Size += 4
|
||||
Symgrow(ctxt, s, s.Size)
|
||||
|
|
@ -360,7 +360,7 @@ func relocsym(s *LSym) {
|
|||
Diag("unhandled relocation for %s (type %d rtype %d)", r.Sym.Name, r.Sym.Type, r.Type)
|
||||
}
|
||||
}
|
||||
if r.Sym != nil && r.Sym.Type != obj.STLSBSS && !r.Sym.Reachable {
|
||||
if r.Sym != nil && r.Sym.Type != obj.STLSBSS && !r.Sym.Attr.Reachable() {
|
||||
Diag("unreachable sym in relocation: %s %s", s.Name, r.Sym.Name)
|
||||
}
|
||||
|
||||
|
|
@ -633,7 +633,7 @@ func dynrelocsym(s *LSym) {
|
|||
if targ == nil {
|
||||
continue
|
||||
}
|
||||
if !targ.Reachable {
|
||||
if !targ.Attr.Reachable() {
|
||||
Diag("internal inconsistency: dynamic symbol %s is not reachable.", targ.Name)
|
||||
}
|
||||
if r.Sym.Plt == -2 && r.Sym.Got != -2 { // make dynimport JMP table for PE object files.
|
||||
|
|
@ -668,7 +668,7 @@ func dynrelocsym(s *LSym) {
|
|||
for ri := 0; ri < len(s.R); ri++ {
|
||||
r = &s.R[ri]
|
||||
if r.Sym != nil && r.Sym.Type == obj.SDYNIMPORT || r.Type >= 256 {
|
||||
if r.Sym != nil && !r.Sym.Reachable {
|
||||
if r.Sym != nil && !r.Sym.Attr.Reachable() {
|
||||
Diag("internal inconsistency: dynamic symbol %s is not reachable.", r.Sym.Name)
|
||||
}
|
||||
Thearch.Adddynrel(s, r)
|
||||
|
|
@ -763,7 +763,7 @@ func Codeblk(addr int64, size int64) {
|
|||
|
||||
var sym *LSym
|
||||
for sym = Ctxt.Textp; sym != nil; sym = sym.Next {
|
||||
if !sym.Reachable {
|
||||
if !sym.Attr.Reachable() {
|
||||
continue
|
||||
}
|
||||
if sym.Value >= addr {
|
||||
|
|
@ -774,7 +774,7 @@ func Codeblk(addr int64, size int64) {
|
|||
eaddr := addr + size
|
||||
var q []byte
|
||||
for ; sym != nil; sym = sym.Next {
|
||||
if !sym.Reachable {
|
||||
if !sym.Attr.Reachable() {
|
||||
continue
|
||||
}
|
||||
if sym.Value >= eaddr {
|
||||
|
|
@ -938,19 +938,19 @@ func addstrdata(name string, value string) {
|
|||
|
||||
s := Linklookup(Ctxt, name, 0)
|
||||
s.Size = 0
|
||||
s.Dupok = 1
|
||||
reachable := s.Reachable
|
||||
s.Attr |= AttrDuplicateOK
|
||||
reachable := s.Attr.Reachable()
|
||||
Addaddr(Ctxt, s, sp)
|
||||
adduintxx(Ctxt, s, uint64(len(value)), Thearch.Ptrsize)
|
||||
|
||||
// addstring, addaddr, etc., mark the symbols as reachable.
|
||||
// In this case that is not necessarily true, so stick to what
|
||||
// we know before entering this function.
|
||||
s.Reachable = reachable
|
||||
s.Attr.Set(AttrReachable, reachable)
|
||||
|
||||
strdata = append(strdata, s)
|
||||
|
||||
sp.Reachable = reachable
|
||||
sp.Attr.Set(AttrReachable, reachable)
|
||||
}
|
||||
|
||||
func checkstrdata() {
|
||||
|
|
@ -967,7 +967,7 @@ func Addstring(s *LSym, str string) int64 {
|
|||
if s.Type == 0 {
|
||||
s.Type = obj.SNOPTRDATA
|
||||
}
|
||||
s.Reachable = true
|
||||
s.Attr |= AttrReachable
|
||||
r := int32(s.Size)
|
||||
n := len(str) + 1
|
||||
if s.Name == ".shstrtab" {
|
||||
|
|
@ -987,8 +987,8 @@ func addgostring(s *LSym, symname, str string) {
|
|||
if sym.Type != obj.Sxxx {
|
||||
Diag("duplicate symname in addgostring: %s", symname)
|
||||
}
|
||||
sym.Reachable = true
|
||||
sym.Local = true
|
||||
sym.Attr |= AttrReachable
|
||||
sym.Attr |= AttrLocal
|
||||
sym.Type = obj.SRODATA
|
||||
sym.Size = int64(len(str))
|
||||
sym.P = []byte(str)
|
||||
|
|
@ -1001,7 +1001,7 @@ func addinitarrdata(s *LSym) {
|
|||
sp := Linklookup(Ctxt, p, 0)
|
||||
sp.Type = obj.SINITARR
|
||||
sp.Size = 0
|
||||
sp.Dupok = 1
|
||||
sp.Attr |= AttrDuplicateOK
|
||||
Addaddr(Ctxt, sp, s)
|
||||
}
|
||||
|
||||
|
|
@ -1146,14 +1146,14 @@ func dodata() {
|
|||
datap = nil
|
||||
|
||||
for _, s := range Ctxt.Allsym {
|
||||
if !s.Reachable || s.Special != 0 {
|
||||
if !s.Attr.Reachable() || s.Attr.Special() {
|
||||
continue
|
||||
}
|
||||
if obj.STEXT < s.Type && s.Type < obj.SXREF {
|
||||
if s.Onlist != 0 {
|
||||
if s.Attr.OnList() {
|
||||
log.Fatalf("symbol %s listed multiple times", s.Name)
|
||||
}
|
||||
s.Onlist = 1
|
||||
s.Attr |= AttrOnList
|
||||
if last == nil {
|
||||
datap = s
|
||||
} else {
|
||||
|
|
@ -1636,7 +1636,7 @@ func textbuildid() {
|
|||
}
|
||||
|
||||
sym := Linklookup(Ctxt, "go.buildid", 0)
|
||||
sym.Reachable = true
|
||||
sym.Attr |= AttrReachable
|
||||
// The \xff is invalid UTF-8, meant to make it less likely
|
||||
// to find one of these accidentally.
|
||||
data := "\xff Go build ID: " + strconv.Quote(buildid) + "\n \xff"
|
||||
|
|
@ -1813,12 +1813,12 @@ func address() {
|
|||
xdefine("runtime.etypelink", obj.SRODATA, int64(typelink.Vaddr+typelink.Length))
|
||||
|
||||
sym := Linklookup(Ctxt, "runtime.gcdata", 0)
|
||||
sym.Local = true
|
||||
sym.Attr |= AttrLocal
|
||||
xdefine("runtime.egcdata", obj.SRODATA, Symaddr(sym)+sym.Size)
|
||||
Linklookup(Ctxt, "runtime.egcdata", 0).Sect = sym.Sect
|
||||
|
||||
sym = Linklookup(Ctxt, "runtime.gcbss", 0)
|
||||
sym.Local = true
|
||||
sym.Attr |= AttrLocal
|
||||
xdefine("runtime.egcbss", obj.SRODATA, Symaddr(sym)+sym.Size)
|
||||
Linklookup(Ctxt, "runtime.egcbss", 0).Sect = sym.Sect
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue