Commit 32190b0a authored by Cherry Zhang's avatar Cherry Zhang

[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/+/204826Reviewed-by: default avatarThan McIntosh <thanm@google.com>
parent c6621d92
......@@ -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})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment