Fix a few dwarf64 parsing problems. Nothing fancy.#27
Fix a few dwarf64 parsing problems. Nothing fancy.#27quenelle wants to merge 2 commits into4ad:sparc64from quenelle:dwarf64-fixes
Conversation
This fixes bugs that show up when dwarf from Studio compilers gets mixed in via crt files.
|
More specifically: |
src/debug/dwarf/open.go
Outdated
| x, y := d.info[4], d.info[5] | ||
| if (d.info[0] == 255 && d.info[1] == 255) { | ||
| // 64-bit DWARF has 4 bytes of FF, then 8 byte size, | ||
| // then 2 byte version |
There was a problem hiding this comment.
The formatting seems a bit off here; consider running 'gofmt -w' on this file.
src/debug/dwarf/unit.go
Outdated
| aoff = b.uint32() | ||
| header_bytes_read += 4 | ||
| } else { | ||
| // For now ignore the high bits |
src/debug/dwarf/unit.go
Outdated
| n, u.is64 = b.unitLength() | ||
| vers := b.uint16() | ||
| var header_bytes_read uint | ||
| header_bytes_read = 2 // Not counting size |
There was a problem hiding this comment.
Maybe 'hbytes' instead of 'header_bytes_read' or 'hlen' ?
This fixes bugs that show up when dwarf from Studio compilers gets mixed in via crt files.
binarycrusader
left a comment
There was a problem hiding this comment.
Do all of the Go tests pass still after this change (e.g. ./all.bash)?
aclements
left a comment
There was a problem hiding this comment.
Looks correct to me. Just a few non-semantic changes.
This would be great to upstream separate of the rest of the sparc changes. I'm really surprised this hasn't bitten us before.
| hbcount += 4 | ||
| } else { | ||
| // For now, ignore the high bits | ||
| aoff = uint32(b.uint64()) |
There was a problem hiding this comment.
I'd recommend checking for overflow here. See the equivalent code in Data.parseTypes.
| var n Offset | ||
| n, u.is64 = b.unitLength() | ||
| vers := b.uint16() | ||
| // Count the bytes of header read, not counting size |
There was a problem hiding this comment.
Rather than counting bytes, I'd suggest following what parseTypes does. Here, just say "hdroff := b.off", then below say "b.bytes(int(n - (b.off - hdroff)))".
There was a problem hiding this comment.
I had actually suggested the same thing to Chris offline :-)
I agree. |
|
Sorry for the delay here. Changes needed are:
I've attached a binary that should show the error if you use DWARF() to open it. |
|
I agree pushing this separate from the sparc64 stuff seems fine. |
This fixes bugs that show up when dwarf from Studio compilers
gets mixed in via crt files.