From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26469 invoked by alias); 9 Mar 2009 22:28:29 -0000 Received: (qmail 26445 invoked by uid 22791); 9 Mar 2009 22:28:27 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_31,J_CHICKENPOX_35 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Mar 2009 22:28:23 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id n29MYmGd031272; Mon, 9 Mar 2009 23:34:48 +0100 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id n29MYmFo031269; Mon, 9 Mar 2009 23:34:48 +0100 Date: Mon, 09 Mar 2009 22:28:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix powerpc build with recent binutils Message-ID: <20090309223448.GH16681@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00000.txt.bz2 Hi! When compiling power5+ or earlier ppc/ppc64 glibc with recent gas, several *context*.S and other files fail to assemble. Small testcase: mtfsf 0xff,31,1,0 with gcc-4.4.0 snapshot and 2.19.51.0.2 gas yields with: gcc -c -m32 a.s -v ... as -a32 -mppc -many -V -Qy -o a.o a.s GNU assembler version 2.19.51.0.2 (ppc-redhat-linux) using BFD version version 2.19.51.0.2-16.fc11 20090204 a.s: Assembler messages: a.s:1: Error: junk at end of line: `0' and with say -m32 -mcpu=power4 similarly (-a32 -mpower4 -many -V -Qy passed to gas). With -m32 -mcpu=power6 this of course compiles: gcc -c -m32 -mcpu=power6 a.s -v ... as -a32 -mpower6 -maltivec -maltivec -many -V -Qy -o a.o a.s # no error Fixed thusly, tested on both ppc32 and ppc64. 2009-02-18 Jakub Jelinek * sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S: Use .machine push; .machine "power6" and .machine pop around mtfsf insns outside of _ARCH_PWR6 define. * sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S: Likewise. * sysdeps/powerpc/fpu/tst-setcontext-fpscr.c (_SET_DI_FPSCR): Likewise. * sysdeps/powerpc/fpu/fenv_libc.h (fesetenv_register, relax_fenv_state): Likewise. --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S.jj 2008-11-17 03:49:06.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S 2009-02-18 22:55:07.000000000 +0100 @@ -1,5 +1,6 @@ /* Switch to context. - Copyright (C) 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, 2008, 2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -86,6 +87,8 @@ ENTRY(__novec_setcontext) /* Use the extended four-operand version of the mtfsf insn. */ mtfsf 0xff,fp0,1,0 # else + .machine push + .machine "power6" /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r5,PPC_FEATURE_HAS_DFP beq 5f @@ -96,6 +99,7 @@ ENTRY(__novec_setcontext) 5: mtfsf 0xff,fp0 6: + .machine pop # endif /* _ARCH_PWR6 */ lfd fp29,(SIGCONTEXT_FP_REGS+(PT_R29*8))(r31) lfd fp28,(SIGCONTEXT_FP_REGS+(PT_R28*8))(r31) @@ -374,6 +378,8 @@ L(has_no_vec): /* Use the extended four-operand version of the mtfsf insn. */ mtfsf 0xff,fp0,1,0 # else + .machine push + .machine "power6" /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r5,PPC_FEATURE_HAS_DFP beq 7f @@ -384,6 +390,7 @@ L(has_no_vec): 7: mtfsf 0xff,fp0 8: + .machine pop # endif /* _ARCH_PWR6 */ lfd fp29,(SIGCONTEXT_FP_REGS+(PT_R29*8))(r31) lfd fp28,(SIGCONTEXT_FP_REGS+(PT_R28*8))(r31) --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S.jj 2008-11-17 03:49:30.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S 2009-02-18 22:55:37.000000000 +0100 @@ -1,5 +1,6 @@ /* Save current context and install the given one. - Copyright (C) 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, 2008, 2009 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -180,6 +181,8 @@ ENTRY(__novec_swapcontext) /* Use the extended four-operand version of the mtfsf insn. */ mtfsf 0xff,fp0,1,0 # else + .machine push + .machine "power6" /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r8,PPC_FEATURE_HAS_DFP beq 5f @@ -190,6 +193,7 @@ ENTRY(__novec_swapcontext) 5: mtfsf 0xff,fp0 6: + .machine pop #endif /* _ARCH_PWR6 */ lfd fp29,(SIGCONTEXT_FP_REGS+(PT_R29*8))(r31) lfd fp28,(SIGCONTEXT_FP_REGS+(PT_R28*8))(r31) @@ -672,6 +676,8 @@ L(has_no_vec2): /* Use the extended four-operand version of the mtfsf insn. */ mtfsf 0xff,fp0,1,0 # else + .machine push + .machine "power6" /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r8,PPC_FEATURE_HAS_DFP beq 7f @@ -682,6 +688,7 @@ L(has_no_vec2): 7: mtfsf 0xff,fp0 8: + .machine pop #endif /* _ARCH_PWR6 */ lfd fp29,(SIGCONTEXT_FP_REGS+(PT_R29*8))(r31) lfd fp28,(SIGCONTEXT_FP_REGS+(PT_R28*8))(r31) --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S.jj 2009-01-30 21:30:33.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S 2009-02-18 22:52:48.000000000 +0100 @@ -430,6 +430,8 @@ ENTRY(__CONTEXT_FUNC_NAME) /* Use the extended four-operand version of the mtfsf insn. */ mtfsf 0xff,fp31,1,0 # else + .machine push + .machine "power6" /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r7,PPC_FEATURE_HAS_DFP beq 7f @@ -438,7 +440,7 @@ ENTRY(__CONTEXT_FUNC_NAME) b 8f /* Continue to operate on the FPSCR as if it were 32-bits. */ 7: mtfsf 0xff,fp31 -8: +8: .machine pop #endif /* _ARCH_PWR6 */ lfd fp1,_UC_FREGS+(1*8)(r31) lfd fp2,_UC_FREGS+(2*8)(r31) --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S.jj 2009-01-30 21:29:24.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S 2009-02-18 22:52:39.000000000 +0100 @@ -204,6 +204,8 @@ ENTRY(__CONTEXT_FUNC_NAME) /* Use the extended four-operand version of the mtfsf insn. */ mtfsf 0xff,fp31,1,0 # else + .machine push + .machine "power6" /* Availability of DFP indicates a 64-bit FPSCR. */ andi. r6,r7,PPC_FEATURE_HAS_DFP beq 7f @@ -212,7 +214,7 @@ ENTRY(__CONTEXT_FUNC_NAME) b 8f /* Continue to operate on the FPSCR as if it were 32-bits. */ 7: mtfsf 0xff,fp31 -8: +8: .machine pop # endif /* _ARCH_PWR6 */ lfd fp1,_UC_FREGS+(1*8)(r31) lfd fp2,_UC_FREGS+(2*8)(r31) --- libc/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c.jj 2009-01-30 21:27:24.000000000 +0100 +++ libc/sysdeps/powerpc/fpu/tst-setcontext-fpscr.c 2009-02-18 23:40:01.000000000 +0100 @@ -111,7 +111,11 @@ typedef unsigned int si_fpscr_t __attrib tmp __attribute__ ((__aligned__(8))); \ tmp.fpscr = __fpscr; \ /* Set the entire 64-bit FPSCR. */ \ - __asm__ ("lfd%U0 0,%0; mtfsf 255,0,1,0" : : "m" (tmp.d) : "fr0"); \ + __asm__ ("lfd%U0 0,%0; " \ + ".machine push; " \ + ".machine \"power6\"; " \ + "mtfsf 255,0,1,0; " \ + ".machine pop" : : "m" (tmp.d) : "fr0"); \ tmp.d = 0; \ __asm__("lfd%U0 0,%0" : : "m" (tmp.d) : "fr0"); \ } --- libc/sysdeps/powerpc/fpu/fenv_libc.h.jj 2008-11-17 02:32:11.000000000 +0100 +++ libc/sysdeps/powerpc/fpu/fenv_libc.h 2009-02-18 23:42:15.000000000 +0100 @@ -1,5 +1,5 @@ /* Internal libc stuff for floating point environment routines. - Copyright (C) 1997, 2006, 2008 Free Software Foundation, Inc. + Copyright (C) 1997, 2006, 2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -39,7 +39,10 @@ libm_hidden_proto (__fe_nomask_env) do { \ double d = (env); \ if(GLRO(dl_hwcap) & PPC_FEATURE_HAS_DFP) \ - asm volatile ("mtfsf 0xff,%0,1,0" : : "f" (d)); \ + asm volatile (".machine push; " \ + ".machine \"power6\"; " \ + "mtfsf 0xff,%0,1,0; " \ + ".machine pop" : : "f" (d)); \ else \ asm volatile ("mtfsf 0xff,%0" : : "f" (d)); \ } while(0) @@ -52,8 +55,9 @@ libm_hidden_proto (__fe_nomask_env) functions. */ #define relax_fenv_state() \ do { \ - if(GLRO(dl_hwcap) & PPC_FEATURE_HAS_DFP) \ - asm ("mtfsfi 7,0,1"); \ + if (GLRO(dl_hwcap) & PPC_FEATURE_HAS_DFP) \ + asm (".machine push; .machine \"power6\"; " \ + "mtfsfi 7,0,1; .machine pop"); \ asm ("mtfsfi 7,0"); \ } while(0) Jakub