From 0a3b4106508fbb7e92d7f603e34924779ad308d1 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Mon, 9 Jun 2014 17:24:48 -0500 Subject: [PATCH] FIX: Parse data alignment factor as SLEB128 --- dwarf/frame.go | 4 ++-- dwarf/frame_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dwarf/frame.go b/dwarf/frame.go index 4cd959cc..bd47426b 100644 --- a/dwarf/frame.go +++ b/dwarf/frame.go @@ -29,7 +29,7 @@ type CommonInformationEntry struct { Version uint8 Augmentation string CodeAlignmentFactor uint64 - DataAlignmentFactor uint64 + DataAlignmentFactor int64 ReturnAddressRegister byte InitialInstructions []byte FrameDescriptorEntries []*FrameDescriptorEntry @@ -237,7 +237,7 @@ func parseCodeAlignmentFactor(ctx *parseContext) (parsefunc, *parseContext) { } func parseDataAlignmentFactor(ctx *parseContext) (parsefunc, *parseContext) { - var daf, c = decodeULEB128(ctx.Buf) + var daf, c = decodeSLEB128(ctx.Buf) ctx.Common.DataAlignmentFactor = daf ctx.Length -= c diff --git a/dwarf/frame_test.go b/dwarf/frame_test.go index 26e7b2b4..7603dccb 100644 --- a/dwarf/frame_test.go +++ b/dwarf/frame_test.go @@ -83,8 +83,8 @@ func TestParse(t *testing.T) { t.Fatal("Code Alignment Factor was not parsed correctly") } - if ce.DataAlignmentFactor != 0x7c { - t.Fatal("Data Alignment Factor was not parsed correctly") + if ce.DataAlignmentFactor != -4 { + t.Fatalf("Data Alignment Factor was not parsed correctly got %#v", ce.DataAlignmentFactor) } fe := ce.FrameDescriptorEntries[0] -- GitLab