aboutsummaryrefslogtreecommitdiff
path: root/src/debug/dwarf/buf.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-03-05 15:07:00 -0500
committerAustin Clements <austin@google.com>2015-03-11 21:35:21 +0000
commit9dfbcd8facae22e2be8bc527e1877b1e23812073 (patch)
treee5c8d2c9bf218828bd1a55db0360d1b6d0845cba /src/debug/dwarf/buf.go
parentd533e3955db945072ab2dfcca1cab57099569260 (diff)
downloadgo-9dfbcd8facae22e2be8bc527e1877b1e23812073.tar.xz
debug/dwarf: factor parsing of unit lengths
Many headers in DWARF sections have a "unit length" that can be either 4 bytes or 12 bytes and indicates both the length of the unit and whether the unit is in 32-bit or 64-bit format. Currently, we implement unit length parsing in four different places. Add a "unitLength" method to buf that parses a unit length and use it in these four places. Change-Id: I7950b91caaa92aa5e19aa63debc8ae46178ecc4d Reviewed-on: https://go-review.googlesource.com/7281 Reviewed-by: Nigel Tao <nigeltao@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/debug/dwarf/buf.go')
-rw-r--r--src/debug/dwarf/buf.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/debug/dwarf/buf.go b/src/debug/dwarf/buf.go
index 53c46eb4b8..2ade0bd76a 100644
--- a/src/debug/dwarf/buf.go
+++ b/src/debug/dwarf/buf.go
@@ -163,6 +163,17 @@ func (b *buf) addr() uint64 {
return 0
}
+func (b *buf) unitLength() (length Offset, dwarf64 bool) {
+ length = Offset(b.uint32())
+ if length == 0xffffffff {
+ dwarf64 = true
+ length = Offset(b.uint64())
+ } else if length >= 0xfffffff0 {
+ b.error("unit length has reserved value")
+ }
+ return
+}
+
func (b *buf) error(s string) {
if b.err == nil {
b.data = nil