The arm ld.so code has

#define _BM(x)  (x == 32? ~0 : ~(-(1UL << (x))))

and uses _BM(32) in several places.  For some reason clang doesn't
realize that the ~(-(1UL << (x))) branch is dead and warns that we
shift a 32-bit integer by 32 bits.  Arguably a bug in clang, but I
noticed that the i386 code simply uses:

#define _BM(x)  (~(-(1ULL << (x))))

which makes the problem go away.  I also changed the type of
reloc_target_bitmask from 'int' to 'long' to match the i386 code.

ok?


Index: libexec/ld.so/arm/rtld_machine.c
===================================================================
RCS file: /cvs/src/libexec/ld.so/arm/rtld_machine.c,v
retrieving revision 1.25
diff -u -p -r1.25 rtld_machine.c
--- libexec/ld.so/arm/rtld_machine.c    24 Jan 2017 07:48:37 -0000      1.25
+++ libexec/ld.so/arm/rtld_machine.c    14 Nov 2017 10:21:55 -0000
@@ -106,8 +106,9 @@ static int reloc_target_flags[] = {
 #define RELOC_USE_ADDEND(t)            ((reloc_target_flags[t] & _RF_A) != 0)
 #define RELOC_TARGET_SIZE(t)           ((reloc_target_flags[t] >> 8) & 0xff)
 #define RELOC_VALUE_RIGHTSHIFT(t)      (reloc_target_flags[t] & 0xff)
-static int reloc_target_bitmask[] = {
-#define _BM(x)  (x == 32? ~0 : ~(-(1UL << (x))))
+
+static long reloc_target_bitmask[] = {
+#define _BM(x)  (~(-(1ULL << (x))))
        _BM(0),         /*  0 NONE */
        _BM(24),        /*  1 PC24 */
        _BM(32),        /*  2 ABS32 */

Reply via email to