1
0
mirror of https://github.com/golang/go synced 2024-11-23 00:10:07 -07:00

cmd/link: add DW_AT_go_runtime_type to unsafe.Pointer and fix it for

uintptr

Adds the DW_AT_go_runtime_type attribute to the debug_info entry for
unsafe.Pointer (which is special) and fixes the debug_info entry of
uintptr so that its DW_AT_go_runtime_type attribute has the proper
class (it was accidentally using DW_CLS_ADDRESS instead of
DW_CLS_GO_TYPEREF)

Change-Id: I52e18593935fbda9bc425e849f4c7f50e9144ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/558275
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
This commit is contained in:
Alessandro Arzilli 2024-01-24 18:10:47 +01:00 committed by Cherry Mui
parent 923ab13f9b
commit b89ad46451
2 changed files with 8 additions and 6 deletions

View File

@ -834,6 +834,7 @@ var abbrevs = [DW_NABRV]dwAbbrev{
DW_CHILDREN_no,
[]dwAttrForm{
{DW_AT_name, DW_FORM_string},
{DW_AT_go_runtime_type, DW_FORM_addr},
},
},

View File

@ -1754,12 +1754,13 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
// Some types that must exist to define other ones (uintptr in particular
// is needed for array size)
d.mkBuiltinType(ctxt, dwarf.DW_ABRV_BARE_PTRTYPE, "unsafe.Pointer")
die := d.mkBuiltinType(ctxt, dwarf.DW_ABRV_BASETYPE, "uintptr")
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_unsigned, 0)
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, int64(d.arch.PtrSize), 0)
newattr(die, dwarf.DW_AT_go_kind, dwarf.DW_CLS_CONSTANT, objabi.KindUintptr, 0)
newattr(die, dwarf.DW_AT_go_runtime_type, dwarf.DW_CLS_ADDRESS, 0, dwSym(d.lookupOrDiag("type:uintptr")))
unsafeptrDie := d.mkBuiltinType(ctxt, dwarf.DW_ABRV_BARE_PTRTYPE, "unsafe.Pointer")
newattr(unsafeptrDie, dwarf.DW_AT_go_runtime_type, dwarf.DW_CLS_GO_TYPEREF, 0, dwSym(d.lookupOrDiag("type:unsafe.Pointer")))
uintptrDie := d.mkBuiltinType(ctxt, dwarf.DW_ABRV_BASETYPE, "uintptr")
newattr(uintptrDie, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_unsigned, 0)
newattr(uintptrDie, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, int64(d.arch.PtrSize), 0)
newattr(uintptrDie, dwarf.DW_AT_go_kind, dwarf.DW_CLS_CONSTANT, objabi.KindUintptr, 0)
newattr(uintptrDie, dwarf.DW_AT_go_runtime_type, dwarf.DW_CLS_GO_TYPEREF, 0, dwSym(d.lookupOrDiag("type:uintptr")))
d.uintptrInfoSym = d.mustFind("uintptr")