diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2017-04-20 07:13:02 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-04-20 21:56:23 +0000 |
| commit | 405a280d01ee6434eea306e3f849ba0586cc8f78 (patch) | |
| tree | 33242762270b6600e26e6b4b106d238718af1867 /src/cmd/internal/obj/objfile.go | |
| parent | 950fa673a57ed2e55d1c992c7c34c6d251cb88fd (diff) | |
| download | go-405a280d01ee6434eea306e3f849ba0586cc8f78.tar.xz | |
cmd/internal/obj: eliminate LSym.Version
There were only two versions, 0 and 1,
and the only user of version 1 was the assembler,
to indicate that a symbol was static.
Rename LSym.Version to Static,
and add it to LSym.Attributes.
Simplify call-sites.
Passes toolstash-check.
Change-Id: Iabd39918f5019cce78f381d13f0481ae09f3871f
Reviewed-on: https://go-review.googlesource.com/41201
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/internal/obj/objfile.go')
| -rw-r--r-- | src/cmd/internal/obj/objfile.go | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index d83ccca9a6..b81d569348 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -151,17 +151,13 @@ func (w *objWriter) writeRef(s *LSym, isPath bool) { return } var m map[string]int - switch s.Version { - case 0: + if !s.Static() { m = w.refIdx - case 1: + } else { m = w.vrefIdx - default: - log.Fatalf("%s: invalid version number %d", s.Name, s.Version) } - idx := m[s.Name] - if idx != 0 { + if idx := m[s.Name]; idx != 0 { s.RefIdx = idx return } @@ -171,7 +167,12 @@ func (w *objWriter) writeRef(s *LSym, isPath bool) { } else { w.writeString(s.Name) } - w.writeInt(int64(s.Version)) + // Write "version". + if s.Static() { + w.writeInt(1) + } else { + w.writeInt(0) + } w.nRefs++ s.RefIdx = w.nRefs m[s.Name] = w.nRefs @@ -194,13 +195,13 @@ func (w *objWriter) writeRefs(s *LSym) { w.writeRef(d, false) } for _, f := range pc.File { - fsym := w.ctxt.Lookup(f, 0) + fsym := w.ctxt.Lookup(f) w.writeRef(fsym, true) } for _, call := range pc.InlTree.nodes { w.writeRef(call.Func, false) f, _ := linkgetlineFromPos(w.ctxt, call.Pos) - fsym := w.ctxt.Lookup(f, 0) + fsym := w.ctxt.Lookup(f) w.writeRef(fsym, true) } } @@ -209,12 +210,12 @@ func (w *objWriter) writeRefs(s *LSym) { func (w *objWriter) writeSymDebug(s *LSym) { ctxt := w.ctxt fmt.Fprintf(ctxt.Bso, "%s ", s.Name) - if s.Version != 0 { - fmt.Fprintf(ctxt.Bso, "v=%d ", s.Version) - } if s.Type != 0 { fmt.Fprintf(ctxt.Bso, "%v ", s.Type) } + if s.Static() { + fmt.Fprint(ctxt.Bso, "static ") + } if s.DuplicateOK() { fmt.Fprintf(ctxt.Bso, "dupok ") } @@ -364,14 +365,14 @@ func (w *objWriter) writeSym(s *LSym) { } w.writeInt(int64(len(pc.File))) for _, f := range pc.File { - fsym := ctxt.Lookup(f, 0) + fsym := ctxt.Lookup(f) w.writeRefIndex(fsym) } w.writeInt(int64(len(pc.InlTree.nodes))) for _, call := range pc.InlTree.nodes { w.writeInt(int64(call.Parent)) f, l := linkgetlineFromPos(w.ctxt, call.Pos) - fsym := ctxt.Lookup(f, 0) + fsym := ctxt.Lookup(f) w.writeRefIndex(fsym) w.writeInt(int64(l)) w.writeRefIndex(call.Func) @@ -456,7 +457,7 @@ func (ctxt *Link) dwarfSym(s *LSym) *LSym { ctxt.Diag("dwarfSym of non-TEXT %v", s) } if s.Func.dwarfSym == nil { - s.Func.dwarfSym = ctxt.Lookup(dwarf.InfoPrefix+s.Name, int(s.Version)) + s.Func.dwarfSym = ctxt.LookupDerived(s, dwarf.InfoPrefix+s.Name) } return s.Func.dwarfSym } @@ -472,5 +473,5 @@ func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym) { if ctxt.DebugInfo != nil { vars = ctxt.DebugInfo(s, curfn) } - dwarf.PutFunc(dwCtxt{ctxt}, dsym, s.Name, s.Version == 0, s, s.Size, vars) + dwarf.PutFunc(dwCtxt{ctxt}, dsym, s.Name, !s.Static(), s, s.Size, vars) } |
