1
0
mirror of https://github.com/golang/go synced 2024-11-20 00:04:43 -07:00

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 <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>
This commit is contained in:
Heschi Kreinick 2017-07-26 15:58:25 -04:00
parent 1d07ed1579
commit 37dbfc51b0
2 changed files with 2 additions and 5 deletions

View File

@ -383,7 +383,7 @@ var abbrevs = [DW_NABRV]dwAbbrev{
DW_CHILDREN_no, DW_CHILDREN_no,
[]dwAttrForm{ []dwAttrForm{
{DW_AT_name, DW_FORM_string}, {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_type, DW_FORM_ref_addr},
{DW_AT_go_embedded_field, DW_FORM_flag}, {DW_AT_go_embedded_field, DW_FORM_flag},
}, },

View File

@ -286,10 +286,7 @@ func reversetree(list **dwarf.DWDie) {
} }
func newmemberoffsetattr(die *dwarf.DWDie, offs int32) { func newmemberoffsetattr(die *dwarf.DWDie, offs int32) {
var block [20]byte newattr(die, dwarf.DW_AT_data_member_location, dwarf.DW_CLS_CONSTANT, int64(offs), nil)
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)
} }
// GDB doesn't like FORM_addr for AT_location, so emit a // GDB doesn't like FORM_addr for AT_location, so emit a