}
 
 func (ctxt *Link) writeSymDebug(s *LSym) {
-       fmt.Fprintf(ctxt.Bso, "%s ", s.Name)
+       ctxt.writeSymDebugNamed(s, s.Name)
+}
+
+func (ctxt *Link) writeSymDebugNamed(s *LSym, name string) {
+       fmt.Fprintf(ctxt.Bso, "%s ", name)
        if s.Type != 0 {
                fmt.Fprintf(ctxt.Bso, "%v ", s.Type)
        }
 
 
 // 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)
-       }
+
+       debugAsmEmit(ctxt)
 
        genFuncInfoSyms(ctxt)
 
        }
        ctxt.defs = append(ctxt.defs, infosyms...)
 }
+
+// debugDumpAux is a dumper for selected aux symbols.
+func writeAuxSymDebug(ctxt *Link, par *LSym, aux *LSym) {
+       // Most aux symbols (ex: funcdata) are not interesting--
+       // pick out just the DWARF ones for now.
+       if aux.Type != objabi.SDWARFLOC &&
+               aux.Type != objabi.SDWARFINFO &&
+               aux.Type != objabi.SDWARFLINES &&
+               aux.Type != objabi.SDWARFRANGE {
+               return
+       }
+       ctxt.writeSymDebugNamed(aux, "aux for "+par.Name)
+}
+
+func debugAsmEmit(ctxt *Link) {
+       if ctxt.Debugasm > 0 {
+               ctxt.traverseSyms(traverseDefs, ctxt.writeSymDebug)
+               if ctxt.Debugasm > 1 {
+                       fn := func(par *LSym, aux *LSym) {
+                               writeAuxSymDebug(ctxt, par, aux)
+                       }
+                       ctxt.traverseAuxSyms(fn)
+               }
+       }
+}
 
                                        fn(s.Gotype)
                                }
                                if s.Type == objabi.STEXT {
-                                       pc := &s.Func.Pcln
-                                       for _, d := range pc.Funcdata {
-                                               if d != nil {
-                                                       fn(d)
-                                               }
-                                       }
-                                       for _, f := range pc.File {
-                                               if fsym := ctxt.Lookup(f); fsym != nil {
-                                                       fn(fsym)
-                                               }
-                                       }
-                                       for _, call := range pc.InlTree.nodes {
-                                               if call.Func != nil {
-                                                       fn(call.Func)
-                                               }
-                                               f, _ := linkgetlineFromPos(ctxt, call.Pos)
-                                               if fsym := ctxt.Lookup(f); fsym != nil {
-                                                       fn(fsym)
-                                               }
+                                       f := func(parent *LSym, aux *LSym) {
+                                               fn(aux)
                                        }
+                                       ctxt.traverseFuncAux(s, f)
                                }
                        }
                }
        }
 }
+
+func (ctxt *Link) traverseFuncAux(fsym *LSym, fn func(parent *LSym, aux *LSym)) {
+       pc := &fsym.Func.Pcln
+       for _, d := range pc.Funcdata {
+               if d != nil {
+                       fn(fsym, d)
+               }
+       }
+       for _, f := range pc.File {
+               if filesym := ctxt.Lookup(f); filesym != nil {
+                       fn(fsym, filesym)
+               }
+       }
+       for _, call := range pc.InlTree.nodes {
+               if call.Func != nil {
+                       fn(fsym, call.Func)
+               }
+               f, _ := linkgetlineFromPos(ctxt, call.Pos)
+               if filesym := ctxt.Lookup(f); filesym != nil {
+                       fn(fsym, filesym)
+               }
+       }
+       dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym}
+       for _, dws := range dwsyms {
+               if dws == nil || dws.Size == 0 {
+                       continue
+               }
+               fn(fsym, dws)
+       }
+}
+
+// Traverse aux symbols, calling fn for each sym/aux pair.
+func (ctxt *Link) traverseAuxSyms(fn func(parent *LSym, aux *LSym)) {
+       lists := [][]*LSym{ctxt.Text, ctxt.Data, ctxt.ABIAliases}
+       for _, list := range lists {
+               for _, s := range list {
+                       if s.Gotype != nil {
+                               fn(s, s.Gotype)
+                       }
+                       if s.Type != objabi.STEXT {
+                               continue
+                       }
+                       ctxt.traverseFuncAux(s, fn)
+               }
+       }
+}