From 32190b0a492f92871d39dd252c1d2a11cbfbadc8 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sat, 2 Nov 2019 10:42:50 -0400 Subject: [PATCH] [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 --- src/cmd/internal/dwarf/dwarf.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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}) -- 2.48.1