From: Heschi Kreinick Date: Wed, 26 Jul 2017 19:58:25 +0000 (-0400) Subject: cmd/link: emit DW_AT_data_member_location as a constant X-Git-Tag: go1.10beta1~1243 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=37dbfc51b04e13ad3441cf0080a33ae56de77169;p=gostls13.git cmd/link: emit DW_AT_data_member_location as a constant 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor Reviewed-by: David Chase --- diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go index 3fe8c31ea6..3f12811338 100644 --- a/src/cmd/internal/dwarf/dwarf.go +++ b/src/cmd/internal/dwarf/dwarf.go @@ -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}, }, diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index 582aec83b5..6359877a1b 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -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