]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: emit DW_AT_data_member_location as a constant
authorHeschi Kreinick <heschi@google.com>
Wed, 26 Jul 2017 19:58:25 +0000 (15:58 -0400)
committerHeschi Kreinick <heschi@google.com>
Thu, 31 Aug 2017 19:42:23 +0000 (19:42 +0000)
Simplify the DWARF representation of structs by emitting field offsets
as constants rather than location descriptions.

This was not explicitly mentioned as an option in DWARF2. It is
mentioned in DWARF4, but isn't listed in the changes, so it's not clear
if this was always intended to work or is an undocumented change. Either
way, it should be valid DWARF4.

Change-Id: Idf7fdd397a21c8f8745673ecc77ef65afa3ffe1c
Reviewed-on: https://go-review.googlesource.com/51611
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/dwarf/dwarf.go
src/cmd/link/internal/ld/dwarf.go

index 3fe8c31ea60d91eb1a6f65c08f351a10ccfe25c8..3f12811338c84cbbf7b8e7acbba7dabb8b409b62 100644 (file)
@@ -383,7 +383,7 @@ var abbrevs = [DW_NABRV]dwAbbrev{
                DW_CHILDREN_no,
                []dwAttrForm{
                        {DW_AT_name, DW_FORM_string},
-                       {DW_AT_data_member_location, DW_FORM_block1},
+                       {DW_AT_data_member_location, DW_FORM_udata},
                        {DW_AT_type, DW_FORM_ref_addr},
                        {DW_AT_go_embedded_field, DW_FORM_flag},
                },
index 582aec83b5f63cbc019d53ea1330070153c12cbb..6359877a1b4eb8cc910cda5ced1cc487ab62cb60 100644 (file)
@@ -286,10 +286,7 @@ func reversetree(list **dwarf.DWDie) {
 }
 
 func newmemberoffsetattr(die *dwarf.DWDie, offs int32) {
-       var block [20]byte
-       b := append(block[:0], dwarf.DW_OP_plus_uconst)
-       b = dwarf.AppendUleb128(b, uint64(offs))
-       newattr(die, dwarf.DW_AT_data_member_location, dwarf.DW_CLS_BLOCK, int64(len(b)), b)
+       newattr(die, dwarf.DW_AT_data_member_location, dwarf.DW_CLS_CONSTANT, int64(offs), nil)
 }
 
 // GDB doesn't like FORM_addr for AT_location, so emit a