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] readelf.c (print_gdb_index_section): Use unsigned int for 31 bits left shift.


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

Signed-off-by: Mark Wielaard <mjw@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  <mjw@redhat.com>
+
+	* readelf.c (print_gdb_index_section): Use unsigned int for 31 bits
+	left shift.
+
 2014-03-13  Mark Wielaard  <mjw@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


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