From patchwork Tue Jul 21 19:46:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 7784 Received: (qmail 22714 invoked by alias); 21 Jul 2015 19:46:43 -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 22702 invoked by uid 89); 21 Jul 2015 19:46:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Message-ID: <1437507995.19674.136.camel@ubuntu-sellcey> Subject: Re: Another GLIBC build error with GCC6 From: Steve Ellcey Reply-To: To: GNU C Library Date: Tue, 21 Jul 2015 12:46:35 -0700 In-Reply-To: <1437496279.19674.126.camel@ubuntu-sellcey> References: <1437496279.19674.126.camel@ubuntu-sellcey> MIME-Version: 1.0 On Tue, 2015-07-21 at 09:31 -0700, Steve Ellcey wrote: > I just ran into this problem when compiling string/strchr in ILP32 mode > on MIPS: To be complete, I ran into 4 problems while building glibc with the latest top-of-tree GCC. strchrnul.c has the same problems as strchr.c. The definition of DT_EXTRATAGIDX in elf/elf.h also gives a shift overflow warning and elf/dl-dl-deps.c now gives an array out-of-bounds message. Here is a not fully tested, not ready patch that allowed me to do a complete build. I think this new definition of DT_EXTRATAGIDX would give the same result as the old definition. I couldn't see anything to do with dl-deps.c except ignore the warning, maybe someone else has a better idea. Steve Ellcey sellcey@imgtec.com diff --git a/elf/dl-deps.c b/elf/dl-deps.c index eee146a..d4c5c00 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -30,6 +30,8 @@ #include +#include + /* Whether an shared object references one or more auxiliary objects is signaled by the AUXTAG entry in l_info. */ #define AUXTAG (DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM \ @@ -226,7 +228,11 @@ _dl_map_object_deps (struct link_map *map, needed = needed_space; } + /* Blah, blah. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (4.6, "-Warray-bounds"); if (l->l_info[DT_NEEDED] || l->l_info[AUXTAG] || l->l_info[FILTERTAG]) + DIAG_POP_NEEDS_COMMENT; { const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]); struct openaux_args args; diff --git a/elf/elf.h b/elf/elf.h index fbadda4..bc33122 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_Word)-((Elf32_Sword) (tag) & 0x7fffffff)-1) #define DT_EXTRANUM 3 /* Values of `d_un.d_val' in the DT_FLAGS entry. */ diff --git a/string/strchr.c b/string/strchr.c index 5f90075..a6abee0 100644 --- a/string/strchr.c +++ b/string/strchr.c @@ -60,22 +60,19 @@ strchr (const char *s, int c_in) The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - switch (sizeof (longword)) - { - case 4: magic_bits = 0x7efefeffL; break; - case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break; - default: - abort (); - } - /* Set up a longword, each of whose bytes is C. */ +#if __WORDSIZE == 32 + magic_bits = 0x7efefeffL; charmask = c | (c << 8); charmask |= charmask << 16; - if (sizeof (longword) > 4) - /* Do the shift in two steps to avoid a warning if long has 32 bits. */ - charmask |= (charmask << 16) << 16; - if (sizeof (longword) > 8) - abort (); +#elif __WORDSIZE == 64 + magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; + charmask = c | (c << 8); + charmask |= charmask << 16; + charmask |= (charmask << 16) << 16; +#else + #error unexpected integer size strchr() +#endif /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing diff --git a/string/strchrnul.c b/string/strchrnul.c index 2678f1d..849a990 100644 --- a/string/strchrnul.c +++ b/string/strchrnul.c @@ -66,22 +66,19 @@ STRCHRNUL (s, c_in) The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - switch (sizeof (longword)) - { - case 4: magic_bits = 0x7efefeffL; break; - case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break; - default: - abort (); - } - /* Set up a longword, each of whose bytes is C. */ +#if __WORDSIZE == 32 + magic_bits = 0x7efefeffL; charmask = c | (c << 8); charmask |= charmask << 16; - if (sizeof (longword) > 4) - /* Do the shift in two steps to avoid a warning if long has 32 bits. */ - charmask |= (charmask << 16) << 16; - if (sizeof (longword) > 8) - abort (); +#elif __WORDSIZE == 64 + magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; + charmask = c | (c << 8); + charmask |= charmask << 16; + charmask |= (charmask << 16) << 16; +#else + #error unexpected integer size strchr() +#endif /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing