From e72f002ed0f2b13f114be914f63b1ddd276675f8 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Thu, 26 Sep 2019 08:42:48 -0400 Subject: [PATCH] cmd/link: create DWARF types for autos based R_USETYPE relocs 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 TryBot-Result: Gobot Gobot Reviewed-by: Jeremy Faller --- src/cmd/link/internal/ld/dwarf.go | 18 ++++++++++++++++++ src/cmd/link/internal/objfile/objfile.go | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index a24e3538eb..e426a6ba7d 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -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) diff --git a/src/cmd/link/internal/objfile/objfile.go b/src/cmd/link/internal/objfile/objfile.go index 503b53db17..da9a38a6d4 100644 --- a/src/cmd/link/internal/objfile/objfile.go +++ b/src/cmd/link/internal/objfile/objfile.go @@ -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() -- 2.50.0