]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/internal/obj: support -S flag in newobj mode
authorCherry Zhang <cherryyz@google.com>
Wed, 9 Oct 2019 01:43:20 +0000 (21:43 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 10 Oct 2019 22:05:21 +0000 (22:05 +0000)
When the compiler's -S flag is specified, it dumps the
disassembly. Add this when writing the new style object file.

Change-Id: I4cf85e57d22d0ceea1fda6d3b59fe363573659e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/200100
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/internal/obj/objfile.go
src/cmd/internal/obj/objfile2.go

index a27004a389970ca1521e8ca188b5da7f005c01b9..76fbc58f106e510ba9173e5cbfda09b81f81ee77 100644 (file)
@@ -228,8 +228,7 @@ func (w *objWriter) writeRefs(s *LSym) {
        }
 }
 
-func (w *objWriter) writeSymDebug(s *LSym) {
-       ctxt := w.ctxt
+func (ctxt *Link) writeSymDebug(s *LSym) {
        fmt.Fprintf(ctxt.Bso, "%s ", s.Name)
        if s.Type != 0 {
                fmt.Fprintf(ctxt.Bso, "%v ", s.Type)
@@ -309,7 +308,7 @@ func (w *objWriter) writeSymDebug(s *LSym) {
 func (w *objWriter) writeSym(s *LSym) {
        ctxt := w.ctxt
        if ctxt.Debugasm > 0 {
-               w.writeSymDebug(s)
+               w.ctxt.writeSymDebug(s)
        }
 
        w.wr.WriteByte(symPrefix)
index 4043e0b9fe91e7c82f033b8d731df818dbfd430c..c51be0265bd89518888020408feb5af5614ac09c 100644 (file)
@@ -17,6 +17,10 @@ import (
 
 // Entry point of writing new object file.
 func WriteObjFile2(ctxt *Link, b *bio.Writer, pkgpath string) {
+       if ctxt.Debugasm > 0 {
+               ctxt.traverseSyms(traverseDefs, ctxt.writeSymDebug)
+       }
+
        genFuncInfoSyms(ctxt)
 
        w := writer{