From patchwork Fri Jan 23 16:27:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 4777 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Received: (qmail 16190 invoked by alias); 23 Jan 2015 16:27:28 -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 16151 invoked by uid 89); 23 Jan 2015 16:27:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e24smtp03.br.ibm.com Message-ID: <54C2765F.5040207@linux.vnet.ibm.com> Date: Fri, 23 Jan 2015 14:27:11 -0200 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "GNU C. Library" CC: "Carlos O'Donell" Subject: [PATCH] powerpc: Fix ifuncmain6pie failure with GCC 4.9 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15012316-0025-0000-0000-000002E28B7C This patch fix the elf/ifuncmain6pie failure when building with GCC 4.9+. For some reason, the compiler removes if condition at resolve_ifunc (sysdeps/powerpc/powerpc64/dl-machine.h) as dead-code and thus the testcase fails because it branches to an invalid memory location. It fixes my explicit adding a dependency of value based on odp variable to avoid compiler optimization. It fixes BZ#17868. Tested on powerpc64 and powerp64le with GCC 4.9 and GCC 4.8. Carlos, I would like to push it for 2.21. --- * sysdeps/powerpc/powerpc64/dl-machine.h (resolve_ifunc): Force value set dependency from opd value. -- diff --git a/NEWS b/NEWS index fd6da90..00115a7 100644 --- a/NEWS +++ b/NEWS @@ -18,7 +18,7 @@ Version 2.21 17664, 17665, 17668, 17682, 17702, 17717, 17719, 17722, 17723, 17724, 17725, 17732, 17733, 17744, 17745, 17746, 17747, 17748, 17775, 17777, 17780, 17781, 17782, 17791, 17793, 17796, 17797, 17803, 17806, 17834, - 17844, 17848 + 17844, 17848, 17868. * A new semaphore algorithm has been implemented in generic C code for all machines. Previous custom assembly implementations of semaphore were diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index 9448712..47bb5a7 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -623,7 +623,9 @@ resolve_ifunc (Elf64_Addr value, opd.fd_func = func->fd_func + sym_map->l_addr; opd.fd_toc = func->fd_toc + sym_map->l_addr; opd.fd_aux = func->fd_aux; - value = (Elf64_Addr) &opd; + /* GCC 4.9+ eliminates the branch as dead code, force the odp set + dependency. */ + asm ("" : "=r" (value) : "0" (&opd), "X" (opd)); } #endif #endif