This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
- From: Mark Wielaard <mjw at redhat dot com>
- To: libc-alpha at sourceware dot org
- Cc: Josh Stone <jistone at redhat dot com>, Mark Wielaard <mjw at redhat dot com>
- Date: Tue, 24 Mar 2015 11:39:39 +0100
- Subject: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
- Authentication-results: sourceware.org; auth=none
Any use of SHF_EXCLUDE in code that tries to check it against sh_flags
will trigger undefined behaviour because it is defined as a 31 bit shift
against an signed integer. Fix by explicitly using an unsigned int.
---
ChangeLog | 4 ++++
elf/elf.h | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index b0a17b0..bdf899f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-24 Mark Wielaard <mjw@redhat.com>
+
+ * elf/elf.h (SHF_EXCLUDE): Use unsigned 1 for shift.
+
2015-03-23 Roland McGrath <roland@hack.frob.com>
* libio/iofdopen.c: Move FD_FLAGS declaration into its first use,
diff --git a/elf/elf.h b/elf/elf.h
index 496f08d..960a3c3 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -371,7 +371,7 @@ typedef struct
#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
#define SHF_ORDERED (1 << 30) /* Special ordering requirement
(Solaris). */
-#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless
+#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
referenced or allocated (Solaris).*/
/* Section group handling. */
--
1.8.3.1