From 99d6791899c43eb31b4d1896134501d814da7741 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 5 Sep 2017 15:14:09 +0000 Subject: [PATCH] Fix pcprofiledump cross-endian condition (bug 22086). debug/pcprofiledump.c contains code that tries to handle other-endian data. This uses a condition "(word & 0xfffffff0) == bswap_32 (0xdeb00000)". This condition is always false (the LHS always has the low four bits zero, the RHS doesn't); a correct comparison would use 0x0fffffff. This results in -Werror=tautological-compare build failures with the tile version of bits/byteswap.h and mainline GCC. https://sourceware.org/ml/libc-testresults/2017-q3/msg00400.html pcprofiledump.c: In function 'main': pcprofiledump.c:118:39: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] int must_swap = (word & 0xfffffff0) == bswap_32 (0xdeb00000); ^~ This patch fixes the condition. Tested for x86_64, and with build-many-glibcs.py that it fixes the build for tilegx-linux-gnu. (Note that I have not tested the actual pcprofiledump functionality, native or cross endian, which lacks any testsuite coverage.) [BZ #22086] * debug/pcprofiledump.c (main): Use byte-swapped mask when comparing word with byte-swapped constant. --- ChangeLog | 6 ++++++ debug/pcprofiledump.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 00255b71aa..d148e74309 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-09-05 Joseph Myers + + [BZ #22086] + * debug/pcprofiledump.c (main): Use byte-swapped mask when + comparing word with byte-swapped constant. + 2017-09-05 Chris Leonard [BZ #20498] diff --git a/debug/pcprofiledump.c b/debug/pcprofiledump.c index a32cdefcf9..6a9641e803 100644 --- a/debug/pcprofiledump.c +++ b/debug/pcprofiledump.c @@ -115,7 +115,7 @@ main (int argc, char *argv[]) error (EXIT_FAILURE, errno, _("cannot read header")); /* Check whether we have to swap the byte order. */ - int must_swap = (word & 0xfffffff0) == bswap_32 (0xdeb00000); + int must_swap = (word & 0x0fffffff) == bswap_32 (0xdeb00000); if (must_swap) word = bswap_32 (word); -- 2.43.5