aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2024-06-27 14:54:06 +0000
committerThan McIntosh <thanm@google.com>2024-07-30 13:19:19 +0000
commitae33b66c19a2a2cf3b95e67d4cec81b474cf733d (patch)
tree364385f8222de7ed72dc170c0338da878c7b2530
parent13b3af03913e4c875cb153d708b16adb023600f9 (diff)
downloadgo-ae33b66c19a2a2cf3b95e67d4cec81b474cf733d.tar.xz
cmd/link: add variable_parameter attr to functype outparams
When generating DW_TAG_subroutine_type DIEs during linker DWARF type synthesis, ensure that in the list of children of the subroutine type DIE (correspondings to input/output params) the output params are marked with the DW_AT_variable_parameter attribute. In addition, fix up the generated types of the output params: prior to this patch for a given output parameter of type T, we would emit the DIE type as *T (presumably due to how parameter passing/returning worked prior to the register ABI); with this patch the emitted type will just be T, not *T. Fixes #59977. Change-Id: I5b5600be86473695663c75b85baeecad667b9245 Reviewed-on: https://go-review.googlesource.com/c/go/+/595715 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
-rw-r--r--src/cmd/internal/dwarf/dwarf.go24
-rw-r--r--src/cmd/link/internal/ld/dwarf.go10
2 files changed, 30 insertions, 4 deletions
diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go
index 40ec8a6ec2..6d4e78fb26 100644
--- a/src/cmd/internal/dwarf/dwarf.go
+++ b/src/cmd/internal/dwarf/dwarf.go
@@ -338,6 +338,7 @@ const (
DW_ABRV_LEXICAL_BLOCK_SIMPLE
DW_ABRV_STRUCTFIELD
DW_ABRV_FUNCTYPEPARAM
+ DW_ABRV_FUNCTYPEOUTPARAM
DW_ABRV_DOTDOTDOT
DW_ABRV_ARRAYRANGE
DW_ABRV_NULLTYPE
@@ -572,6 +573,8 @@ var abbrevs = []dwAbbrev{
{
DW_TAG_member,
DW_CHILDREN_no,
+ // This abbrev is special-cased by the linker (unlike other DIEs
+ // we don't want a loader.Sym created for this DIE).
[]dwAttrForm{
{DW_AT_name, DW_FORM_string},
{DW_AT_data_member_location, DW_FORM_udata},
@@ -586,15 +589,34 @@ var abbrevs = []dwAbbrev{
DW_CHILDREN_no,
// No name!
+ // This abbrev is special-cased by the linker (unlike other DIEs
+ // we don't want a loader.Sym created for this DIE).
[]dwAttrForm{
{DW_AT_type, DW_FORM_ref_addr},
},
},
+ /* FUNCTYPEOUTPARAM */
+ {
+ DW_TAG_formal_parameter,
+ DW_CHILDREN_no,
+
+ // No name!
+ // This abbrev is special-cased by the linker (unlike other DIEs
+ // we don't want a loader.Sym created for this DIE).
+ []dwAttrForm{
+ {DW_AT_variable_parameter, DW_FORM_flag},
+ {DW_AT_type, DW_FORM_ref_addr},
+ },
+ },
+
/* DOTDOTDOT */
{
DW_TAG_unspecified_parameters,
DW_CHILDREN_no,
+ // No name.
+ // This abbrev is special-cased by the linker (unlike other DIEs
+ // we don't want a loader.Sym created for this DIE).
[]dwAttrForm{},
},
@@ -604,6 +626,8 @@ var abbrevs = []dwAbbrev{
DW_CHILDREN_no,
// No name!
+ // This abbrev is special-cased by the linker (unlike other DIEs
+ // we don't want a loader.Sym created for this DIE).
[]dwAttrForm{
{DW_AT_type, DW_FORM_ref_addr},
{DW_AT_count, DW_FORM_udata},
diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go
index 886c1ff672..1dc31c2565 100644
--- a/src/cmd/link/internal/ld/dwarf.go
+++ b/src/cmd/link/internal/ld/dwarf.go
@@ -286,7 +286,7 @@ func (d *dwctxt) newdie(parent *dwarf.DWDie, abbrev int, name string) *dwarf.DWD
var st sym.SymKind
switch abbrev {
- case dwarf.DW_ABRV_FUNCTYPEPARAM, dwarf.DW_ABRV_DOTDOTDOT, dwarf.DW_ABRV_STRUCTFIELD, dwarf.DW_ABRV_ARRAYRANGE:
+ case dwarf.DW_ABRV_FUNCTYPEPARAM, dwarf.DW_ABRV_FUNCTYPEOUTPARAM, dwarf.DW_ABRV_DOTDOTDOT, dwarf.DW_ABRV_STRUCTFIELD, dwarf.DW_ABRV_ARRAYRANGE:
// There are no relocations against these dies, and their names
// are not unique, so don't create a symbol.
return die
@@ -622,8 +622,9 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
for i := 0; i < nfields; i++ {
s := decodetypeFuncOutType(d.ldr, d.arch, gotype, &relocs, i)
sn := d.ldr.SymName(s)
- fld := d.newdie(die, dwarf.DW_ABRV_FUNCTYPEPARAM, sn[5:])
- d.newrefattr(fld, dwarf.DW_AT_type, d.defptrto(d.defgotype(s)))
+ fld := d.newdie(die, dwarf.DW_ABRV_FUNCTYPEOUTPARAM, sn[5:])
+ newattr(fld, dwarf.DW_AT_variable_parameter, dwarf.DW_CLS_FLAG, 1, 0)
+ d.newrefattr(fld, dwarf.DW_AT_type, d.defgotype(s))
}
case abi.Interface:
@@ -2096,7 +2097,8 @@ func (d *dwctxt) dwarfGenerateDebugSyms() {
seen := loader.MakeBitmap(d.ldr.NSym())
for _, s := range infoSec.syms {
if seen.Has(s) {
- log.Fatalf("symbol %s listed multiple times", d.ldr.SymName(s))
+ log.Fatalf("dwarf symbol %s listed multiple times",
+ d.ldr.SymName(s))
}
seen.Set(s)
}