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 | 74c9cc8394049f68f711e25df413a813dc21f174 (patch) | |
| tree | 976d99d7713324cf96974234e850330ceccc66e6 /src/pkg/debug | |
| parent | 59af2c647bc728270604e8db649d23367060f15d (diff) | |
| download | go-74c9cc8394049f68f711e25df413a813dc21f174.tar.xz | |
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://golang.org/cl/111230044
Diffstat (limited to 'src/pkg/debug')
| -rw-r--r-- | src/pkg/debug/dwarf/type.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pkg/debug/dwarf/type.go b/src/pkg/debug/dwarf/type.go index 68866d0b7b..7b5f1cf7b9 100644 --- a/src/pkg/debug/dwarf/type.go +++ b/src/pkg/debug/dwarf/type.go @@ -370,16 +370,22 @@ func (d *Data) readType(name string, r typeReader, off Offset, typeCache map[Off // but haven't seen that in the wild yet. switch kid.Tag { case TagSubrangeType: - max, ok := kid.Val(AttrUpperBound).(int64) + count, ok := kid.Val(AttrCount).(int64) if !ok { - max = -2 // Count == -1, as in x[]. + // Old binaries may have an upper bound instead. + count, ok = kid.Val(AttrUpperBound).(int64) + if ok { + count++ // Length is one more than upper bound. + } else { + count = -1 // As in x[]. + } } if ndim == 0 { - t.Count = max + 1 + t.Count = count } else { // Multidimensional array. // Create new array type underneath this one. - t.Type = &ArrayType{Type: t.Type, Count: max + 1} + t.Type = &ArrayType{Type: t.Type, Count: count} } ndim++ case TagEnumerationType: |
