]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: add DW_AT_go_runtime_type to unsafe.Pointer and fix it for
authorAlessandro Arzilli <alessandro.arzilli@gmail.com>
Wed, 24 Jan 2024 17:10:47 +0000 (18:10 +0100)
committerCherry Mui <cherryyz@google.com>
Tue, 30 Jan 2024 14:41:56 +0000 (14:41 +0000)
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>
src/cmd/internal/dwarf/dwarf.go
src/cmd/link/internal/ld/dwarf.go

index 3e87e590fb02846f235e3e7b7596e54545562a1a..d10b3731df4c4988e247c1586dd6d51c9ba063ef 100644 (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},
                },
        },
 
index ee7eb266bc39cdf8f1890bd7a82fb04c0d11dd94..f3296e1728f2efefa3933bde34a479aded754ff6 100644 (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")