-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a few dwarf64 parsing problems. Nothing fancy. #27
base: sparc64
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/now/now,/
src/debug/dwarf/unit.go
Outdated
@@ -62,12 +62,23 @@ func (d *Data) parseUnits() ([]unit, error) { | |||
var n Offset | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all of the Go tests pass still after this change (e.g. ./all.bash)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend checking for overflow here. See the equivalent code in Data.parseTypes.
@@ -62,12 +62,24 @@ func (d *Data) parseUnits() ([]unit, error) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.