]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: create DWARF types for autos based R_USETYPE relocs
authorThan McIntosh <thanm@google.com>
Thu, 26 Sep 2019 12:42:48 +0000 (08:42 -0400)
committerThan McIntosh <thanm@google.com>
Fri, 27 Sep 2019 13:56:45 +0000 (13:56 +0000)
Switch the linker over to use dummy R_USETYPE relocations on DWARF
subprogram DIEs as a means of insuring that DWARF types are created
for types of autotmp values used in live functions.

This change is part of a series intended to clean up handling of
autotmp types and remove use of autom's in the compiler and linker.

Updates #34554.

Change-Id: Ic74da6bd723ab7e4d8a16ad46e23228650d4b525
Reviewed-on: https://go-review.googlesource.com/c/go/+/197498
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/objfile/objfile.go

index a24e3538eb6ce40d20705a58139bd655dd04060d..e426a6ba7def0d32cc9a7807a056f97a45bc66f9 100644 (file)
@@ -1766,6 +1766,24 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
        // Create DIEs for global variables and the types they use.
        genasmsym(ctxt, defdwsymb)
 
+       // Create DIEs for variable types indirectly referenced by function
+       // autos (which may not appear directly as param/var DIEs).
+       for _, lib := range ctxt.Library {
+               for _, unit := range lib.Units {
+                       lists := [][]*sym.Symbol{unit.AbsFnDIEs, unit.FuncDIEs}
+                       for _, list := range lists {
+                               for _, s := range list {
+                                       for i := 0; i < len(s.R); i++ {
+                                               r := &s.R[i]
+                                               if r.Type == objabi.R_USETYPE {
+                                                       defgotype(ctxt, r.Sym)
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
        synthesizestringtypes(ctxt, dwtypes.Child)
        synthesizeslicetypes(ctxt, dwtypes.Child)
        synthesizemaptypes(ctxt, dwtypes.Child)
index 503b53db17b478d1a96f5d83deeb666c5a3d3b10..da9a38a6d49d6fe129efcd29c24031624c4f2a9c 100644 (file)
@@ -342,6 +342,10 @@ overwrite:
                        }
                }
 
+               // Temporary: zero out the autom list after we've read it.
+               // In a subsequent patch we'll remove autom handling more completely.
+               pc.Autom = nil
+
                pc.Pcsp.P = r.readData()
                pc.Pcfile.P = r.readData()
                pc.Pcline.P = r.readData()