]> Cypherpunks repositories - gostls13.git/commitdiff
debug/dwarf: skip over zero-length compilation units
authorRuss Cox <rsc@golang.org>
Tue, 20 Apr 2021 19:41:24 +0000 (15:41 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 23 Apr 2021 21:42:56 +0000 (21:42 +0000)
DWARF sections generated by mingw-clang seem to include these
(not often - only one out of many in the binary that I am looking at).
Skipping over them, everything parses correctly.

This makes TestDefaultLinkerDWARF pass on windows/arm64.

Change-Id: Ie4a7daa1423f51cbc8c4aac88b1d27c3b52ee880
Reviewed-on: https://go-review.googlesource.com/c/go/+/312031
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/debug/dwarf/unit.go

index 29a744fd184895cf382dc068dd65c1e425c9580c..9b3d6e902d9993274e16dcbf0129a02a82497658 100644 (file)
@@ -48,7 +48,9 @@ func (d *Data) parseUnits() ([]unit, error) {
                        break
                }
                b.skip(int(len))
-               nunit++
+               if len > 0 {
+                       nunit++
+               }
        }
        if b.err != nil {
                return nil, b.err
@@ -61,7 +63,9 @@ func (d *Data) parseUnits() ([]unit, error) {
                u := &units[i]
                u.base = b.off
                var n Offset
-               n, u.is64 = b.unitLength()
+               for n == 0 {
+                       n, u.is64 = b.unitLength()
+               }
                dataOff := b.off
                vers := b.uint16()
                if vers < 2 || vers > 5 {