From patchwork Tue Sep 5 15:14:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 810193 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84188-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="w+UPNUyg"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmqyn6Ssfz9s76 for ; Wed, 6 Sep 2017 01:15:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=mECqOx2tAsedwnigesosW+7nHaV95 oY6Dr9xy/gNkPYH6H2XzQZUXgbH4UEC2gZMm5fQcthNHWnXD0E7Cq3TSjQm4Hh2X QNnqO6+L7Lg6urzE/5++6J/RNImz4Ch65mpWhO2WBd98desOp9zy6wm6uHueAahu 62pYEToVEMqcBA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=xaZtA1zdXmWmtlTb3BdlChLu4FY=; b=w+U PNUygllJDoiK0piyVEB5IyfuJoxEhHuf5hM4ZrkcO48GHBUbDj54EHhQjvxeS4J3 HgkwlYnobJ2uzT7VXY3/GtcZFnGz19bRDEw1jVxvIkuAuZRA6hovHO+naW+RqgFu BrcLti4aU898eHQE+LcsXTF/KSN7FaJWW7CIS5Nk= Received: (qmail 104582 invoked by alias); 5 Sep 2017 15:15:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 103239 invoked by uid 89); 5 Sep 2017 15:15:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=Hx-languages-length:1694 X-HELO: relay1.mentorg.com Date: Tue, 5 Sep 2017 15:14:49 +0000 From: Joseph Myers To: Subject: Fix pcprofiledump cross-endian condition (bug 22086) [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) 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.) Committed. 2017-09-05 Joseph Myers [BZ #22086] * debug/pcprofiledump.c (main): Use byte-swapped mask when comparing word with byte-swapped constant. diff --git a/debug/pcprofiledump.c b/debug/pcprofiledump.c index a32cdef..6a9641e 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);