diff options
author | Rob Pike <r@golang.org> | 2014-07-16 18:26:50 +0000 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2014-07-16 18:26:50 +0000 |
commit | 5e0bdffc3d69b7a60017a0f8dbd0afb38793e656 (patch) | |
tree | 551270da6fecb202bf8d77e61ec5aac992bc8b9f /src/cmd/ld | |
parent | cc88e0fd82304c16a4750c2633c9f5fbdff0d0ae (diff) | |
download | go-5e0bdffc3d69b7a60017a0f8dbd0afb38793e656.tar.gz |
cmd/ld: use count, not upper bound, in type of array
DWARF says only one is necessary.
The count is preferable because it admits 0-length arrays.
Update debug/dwarf to handle either form.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/111230044
Diffstat (limited to 'src/cmd/ld')
-rw-r--r-- | src/cmd/ld/dwarf.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/ld/dwarf.c b/src/cmd/ld/dwarf.c index c2fd07702..c9bb1bd8f 100644 --- a/src/cmd/ld/dwarf.c +++ b/src/cmd/ld/dwarf.c @@ -266,7 +266,7 @@ static struct DWAbbrev { DW_TAG_subrange_type, DW_CHILDREN_no, // No name! DW_AT_type, DW_FORM_ref_addr, - DW_AT_upper_bound, DW_FORM_udata, + DW_AT_count, DW_FORM_udata, 0, 0 }, @@ -992,7 +992,8 @@ defgotype(LSym *gotype) s = decodetype_arrayelem(gotype); newrefattr(die, DW_AT_type, defgotype(s)); fld = newdie(die, DW_ABRV_ARRAYRANGE, "range"); - newattr(fld, DW_AT_upper_bound, DW_CLS_CONSTANT, decodetype_arraylen(gotype)-1, 0); // -1: want upper bound, not count. + // use actual length not upper bound; correct for 0-length arrays. + newattr(fld, DW_AT_count, DW_CLS_CONSTANT, decodetype_arraylen(gotype), 0); newrefattr(fld, DW_AT_type, find_or_diag(&dwtypes, "uintptr")); break; @@ -1256,7 +1257,7 @@ synthesizemaptypes(DWDie *die) newattr(dwhk, DW_AT_byte_size, DW_CLS_CONSTANT, BucketSize * keysize, 0); newrefattr(dwhk, DW_AT_type, indirect_key ? defptrto(keytype) : keytype); fld = newdie(dwhk, DW_ABRV_ARRAYRANGE, "size"); - newattr(fld, DW_AT_upper_bound, DW_CLS_CONSTANT, BucketSize, 0); + newattr(fld, DW_AT_count, DW_CLS_CONSTANT, BucketSize, 0); newrefattr(fld, DW_AT_type, find_or_diag(&dwtypes, "uintptr")); // Construct type to represent an array of BucketSize values @@ -1266,7 +1267,7 @@ synthesizemaptypes(DWDie *die) newattr(dwhv, DW_AT_byte_size, DW_CLS_CONSTANT, BucketSize * valsize, 0); newrefattr(dwhv, DW_AT_type, indirect_val ? defptrto(valtype) : valtype); fld = newdie(dwhv, DW_ABRV_ARRAYRANGE, "size"); - newattr(fld, DW_AT_upper_bound, DW_CLS_CONSTANT, BucketSize, 0); + newattr(fld, DW_AT_count, DW_CLS_CONSTANT, BucketSize, 0); newrefattr(fld, DW_AT_type, find_or_diag(&dwtypes, "uintptr")); // Construct bucket<K,V> |