]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/internal/dwarf: expand import path in function DIE
authorCherry Zhang <cherryyz@google.com>
Sat, 2 Nov 2019 14:42:50 +0000 (10:42 -0400)
committerCherry Zhang <cherryyz@google.com>
Sun, 3 Nov 2019 04:58:01 +0000 (04:58 +0000)
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 <thanm@google.com>
src/cmd/internal/dwarf/dwarf.go

index 740b04f6065b38e8764cbb2b5f5d6d35fa5f7d23..56b44a1ab5acac19b2d0c14d6caa1e70f72dac0a 100644 (file)
@@ -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})