From: Cherry Zhang Date: Sat, 2 Nov 2019 14:42:50 +0000 (-0400) Subject: [dev.link] cmd/internal/dwarf: expand import path in function DIE X-Git-Tag: go1.14beta1~292^2^2~4 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=32190b0a492f92871d39dd252c1d2a11cbfbadc8;p=gostls13.git [dev.link] cmd/internal/dwarf: expand import path in function DIE Currently, at compile time we emit a function DIE with '"".' in the function name, and we expand it at link time, with a really ugly function. We can just expand it at compile time instead. This way, we don't need to modify the symbol content at link time, and also no need to allocate memory for that. Keep the linker expansion, in case the compiler is invoked without the import path. Change-Id: Id53cd2e2d3eb61efceb8d44479c4b6ef890baa43 Reviewed-on: https://go-review.googlesource.com/c/go/+/204826 Reviewed-by: Than McIntosh --- diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go index 740b04f606..56b44a1ab5 100644 --- a/src/cmd/internal/dwarf/dwarf.go +++ b/src/cmd/internal/dwarf/dwarf.go @@ -1372,7 +1372,13 @@ func PutDefaultFunc(ctxt Context, s *FnState) error { abbrev := DW_ABRV_FUNCTION Uleb128put(ctxt, s.Info, int64(abbrev)) - putattr(ctxt, s.Info, DW_ABRV_FUNCTION, DW_FORM_string, DW_CLS_STRING, int64(len(s.Name)), s.Name) + // Expand '"".' to import path. + name := s.Name + if s.Importpath != "" { + name = strings.Replace(name, "\"\".", objabi.PathToPrefix(s.Importpath)+".", -1) + } + + putattr(ctxt, s.Info, DW_ABRV_FUNCTION, DW_FORM_string, DW_CLS_STRING, int64(len(name)), name) putattr(ctxt, s.Info, abbrev, DW_FORM_addr, DW_CLS_ADDRESS, 0, s.StartPC) putattr(ctxt, s.Info, abbrev, DW_FORM_addr, DW_CLS_ADDRESS, s.Size, s.StartPC) putattr(ctxt, s.Info, abbrev, DW_FORM_block1, DW_CLS_BLOCK, 1, []byte{DW_OP_call_frame_cfa})