This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libdwfl: __libdwfl_frame_reg_[gs]et use uint64_t when checking bits.


Found by gcc -fsanitize=undefined while running the backtrace-core-ppc test.
runtime error: shift exponent 45 is too large for 32-bit type 'unsigned int'

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 libdwfl/ChangeLog      |    6 ++++++
 libdwfl/frame_unwind.c |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index e93d50c..31697ce 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,9 @@
+2014-04-22  Mark Wielaard  <mjw@redhat.com>
+
+	* frame_unwind.c (__libdwfl_frame_reg_get): Use uint64_t when
+	checking bits.
+	(__libdwfl_frame_reg_set): Likewise.
+
 2014-03-14  Mark Wielaard  <mjw@redhat.com>
 
 	* Makefile.am: Remove !MUDFLAP and MUDFLAP conditions.
diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c
index dc99e40..18c808b 100644
--- a/libdwfl/frame_unwind.c
+++ b/libdwfl/frame_unwind.c
@@ -57,7 +57,7 @@ __libdwfl_frame_reg_get (Dwfl_Frame *state, unsigned regno, Dwarf_Addr *val)
   if (regno >= ebl_frame_nregs (ebl))
     return false;
   if ((state->regs_set[regno / sizeof (*state->regs_set) / 8]
-       & (1U << (regno % (sizeof (*state->regs_set) * 8)))) == 0)
+       & ((uint64_t) 1U << (regno % (sizeof (*state->regs_set) * 8)))) == 0)
     return false;
   if (val)
     *val = state->regs[regno];
@@ -77,7 +77,7 @@ __libdwfl_frame_reg_set (Dwfl_Frame *state, unsigned regno, Dwarf_Addr val)
   if (ebl_get_elfclass (ebl) == ELFCLASS32)
     val &= 0xffffffff;
   state->regs_set[regno / sizeof (*state->regs_set) / 8] |=
-			      (1U << (regno % (sizeof (*state->regs_set) * 8)));
+		((uint64_t) 1U << (regno % (sizeof (*state->regs_set) * 8)));
   state->regs[regno] = val;
   return true;
 }
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]