From patchwork Tue Aug 4 19:32:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 503785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 C33201402BF for ; Wed, 5 Aug 2015 05:33:36 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=ytQ762kD; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=GUWkDQXzo8eZFLjrVQJRKBMPQgyuf2Sh4fURQjSwVglLiSNBKpKU+ oOwiLC/Iglh5FFUhfMVLrTIfE40BQGbdtF0XRUGfSa3+A6hRwKohy5q2IwfO4Wx8 boXCG0Lwa/eVyEvt5j6rUvjMHFSI5vgofLRyTaSsPsIvUweuNCtqH4= 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:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=6CNicSSf90Pv690fbL8nqVpkbU0=; b=ytQ762kDRGD5sF1bg/Ow0Rp3sDsX vzQac7no5j9UBW4p9wY4jq+9i7c7uxw3Ax0SUEh/IHjLwvhdT0UbQbnaFrZks3NH 9ft+KV7X25uO6ChhRDbgEnm/fb+x+ZYv0EUqLzsWqEsSuK1t/+T5Xg/0XY4pmmY8 U8sKOrG60B782cM= Received: (qmail 3096 invoked by alias); 4 Aug 2015 19:33:30 -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 3083 invoked by uid 89); 4 Aug 2015 19:33:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f45.google.com X-Received: by 10.140.238.86 with SMTP id j83mr10520984qhc.37.1438716806730; Tue, 04 Aug 2015 12:33:26 -0700 (PDT) From: Richard Henderson To: libc-alpha@sourceware.org Cc: carlos@redhat.com Subject: [PATCH] Adjust DT_EXTRATAGIDX to avoid undefined shifts Date: Tue, 4 Aug 2015 12:32:52 -0700 Message-Id: <1438716772-2250-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 Building alphaev67-linux with gcc6 results in Werror: In file included from ../include/elf.h:2:0, from ../sysdeps/alpha/stackinfo.h:24, from ../include/stackinfo.h:24, from ../include/alloca.h:4, from ../stdlib/stdlib.h:492, from ../include/stdlib.h:10, from ../include/atomic.h:48, from dl-deps.c:19: dl-deps.c: In function ‘_dl_map_object_deps’: ../elf/elf.h:804:64: error: result of ‘2147483645 << 1’ requires 33 bits to represent, but ‘int’ only has 32 bits [-Werror=shift-overflow=] #define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) ^ dl-deps.c:36:6: note: in expansion of macro ‘DT_EXTRATAGIDX’ + DT_EXTRATAGIDX (DT_AUXILIARY)) ^ dl-deps.c:229:45: note: in expansion of macro ‘AUXTAG’ if (l->l_info[DT_NEEDED] || l->l_info[AUXTAG] || l->l_info[FILTERTAG]) ^ --- I believe my previous round of testing was done with gcc 4.9.1, which is why I'm a bit late with this report. I haven't tested with gcc5 to see if this is a problem with a released compiler, or if the warning is restricted to the development tree. Given that it affects an installed header, I don't even know if we want to change anything for this release at this date. r~ 2015-08-04 Richard Henderson * elf/elf.h (DT_EXTRATAGIDX): Reformulate to avoid undefined shift. diff --git a/elf/elf.h b/elf/elf.h index fbadda4..daab08f 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -801,7 +801,7 @@ typedef struct range. Be compatible. */ #define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ #define DT_FILTER 0x7fffffff /* Shared object to get values from */ -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRATAGIDX(tag) (-((Elf32_Sword)((Elf32_Word)(tag) * 2) / 2 + 1)) #define DT_EXTRANUM 3 /* Values of `d_un.d_val' in the DT_FLAGS entry. */