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: 8008 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. */