Found by gcc -fsanitize=undefined.
left shift of 1 by 31 places cannot be represented in type 'int'

Signed-off-by: Mark Wielaard <m...@redhat.com>
---
 src/ChangeLog |    5 +++++
 src/readelf.c |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 5eb69d6..874e255 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-22  Mark Wielaard  <m...@redhat.com>
+
+       * readelf.c (print_gdb_index_section): Use unsigned int for 31 bits
+       left shift.
+
 2014-03-13  Mark Wielaard  <m...@redhat.com>
 
        * Makefile.am: Remove no_mudflap.os. Remove libmudflap from all
diff --git a/src/readelf.c b/src/readelf.c
index 8a9543d..da1bf73 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7827,7 +7827,7 @@ print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, 
GElf_Ehdr *ehdr,
              cu_kind = read_4ubyte_unaligned (dbg, readcus);
              cu = cu_kind & ((1 << 24) - 1);
              kind = (cu_kind >> 28) & 7;
-             is_static = cu_kind & (1 << 31);
+             is_static = cu_kind & (1U << 31);
              if (cu > cu_nr - 1)
                printf ("%" PRId32 "T", cu - (uint32_t) cu_nr);
              else
-- 
1.7.1

Reply via email to