public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libdwfl: __libdwfl_frame_reg_[gs]et use uint64_t when checking bits.
@ 2014-04-22 21:58 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2014-04-22 21:58 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-22 21:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-22 21:58 [PATCH] libdwfl: __libdwfl_frame_reg_[gs]et use uint64_t when checking bits Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).