From: Cherry Zhang Date: Mon, 18 May 2020 22:47:17 +0000 (-0400) Subject: [dev.link] cmd/internal/obj: remove asm parameter of NumberSyms X-Git-Tag: go1.16beta1~1378^2~119 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=cf3bf9959ccec7bc2ccf1b685c006298234ef37c;p=gostls13.git [dev.link] cmd/internal/obj: remove asm parameter of NumberSyms Now we have ctxt.IsAsm, use that, instead of passing in a parameter. Change-Id: I81dedbe6459424fa9a4c2bfbd9abd83d83f3a107 Reviewed-on: https://go-review.googlesource.com/c/go/+/234492 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller Reviewed-by: Than McIntosh --- diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go index 4a5dfecf6d..31d8549d2d 100644 --- a/src/cmd/asm/main.go +++ b/src/cmd/asm/main.go @@ -96,7 +96,7 @@ func main() { } } if ok && !*flags.SymABIs { - ctxt.NumberSyms(true) + ctxt.NumberSyms() obj.WriteObjFile(ctxt, buf, *flags.Importpath) } if !ok || diag { diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index ba40582f4f..b258952457 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -789,7 +789,7 @@ func Main(archInit func(*Arch)) { // Write object data to disk. timings.Start("be", "dumpobj") dumpdata() - Ctxt.NumberSyms(false) + Ctxt.NumberSyms() dumpobj() if asmhdr != "" { dumpasmhdr() diff --git a/src/cmd/internal/obj/sym.go b/src/cmd/internal/obj/sym.go index 61ef6ff2ce..4cbcb87b48 100644 --- a/src/cmd/internal/obj/sym.go +++ b/src/cmd/internal/obj/sym.go @@ -164,7 +164,7 @@ func (ctxt *Link) Int64Sym(i int64) *LSym { // Assign index to symbols. // asm is set to true if this is called by the assembler (i.e. not the compiler), // in which case all the symbols are non-package (for now). -func (ctxt *Link) NumberSyms(asm bool) { +func (ctxt *Link) NumberSyms() { if ctxt.Headtype == objabi.Haix { // Data must be sorted to keep a constant order in TOC symbols. // As they are created during Progedit, two symbols can be switched between @@ -181,7 +181,7 @@ func (ctxt *Link) NumberSyms(asm bool) { var idx, nonpkgidx int32 = 0, 0 ctxt.traverseSyms(traverseDefs, func(s *LSym) { - if isNonPkgSym(ctxt, asm, s) { + if isNonPkgSym(ctxt, s) { s.PkgIdx = goobj2.PkgIdxNone s.SymIdx = nonpkgidx if nonpkgidx != int32(len(ctxt.nonpkgdefs)) { @@ -240,7 +240,7 @@ func (ctxt *Link) NumberSyms(asm bool) { }) // Compute a fingerprint of the indices, for exporting. - if !asm { + if !ctxt.IsAsm { h := md5.New() for _, s := range ctxt.defs { h.Write([]byte(s.Name)) @@ -251,8 +251,8 @@ func (ctxt *Link) NumberSyms(asm bool) { // Returns whether s is a non-package symbol, which needs to be referenced // by name instead of by index. -func isNonPkgSym(ctxt *Link, asm bool, s *LSym) bool { - if asm && !s.Static() { +func isNonPkgSym(ctxt *Link, s *LSym) bool { + if ctxt.IsAsm && !s.Static() { // asm symbols are referenced by name only, except static symbols // which are file-local and can be referenced by index. return true