From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25137 invoked by alias); 23 Apr 2004 12:31:04 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 25121 invoked from network); 23 Apr 2004 12:31:03 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sources.redhat.com with SMTP; 23 Apr 2004 12:31:03 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i3NAJH3j004785; Fri, 23 Apr 2004 12:19:17 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i3NAJGnW004778; Fri, 23 Apr 2004 12:19:16 +0200 Date: Fri, 23 Apr 2004 12:31:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] ia64 fix (when building with old GCC), errno optimization Message-ID: <20040423101916.GK5191@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.4i X-SW-Source: 2004-04/txt/msg00084.txt.bz2 Hi! libc-symbols.h/bcopy.S is a fix for a problem reported by David. If a compiler supports hidden, but not HAVE_BUILTIN_REDIRECTION (such as vanilla GCC 3.3.x), bcopy will branch to non-existant symbol. The rest is just optimization, to kill __errno_location PLT slot in libc.so (and libpthread.so) killed. 2004-04-23 Jakub Jelinek * include/libc-symbols.h (HIDDEN_BUILTIN_JUMPTARGET): Define. * sysdeps/ia64/bcopy.S (bcopy): Use it for jump to memmove. * sysdeps/unix/sysv/linux/ia64/sysdep.S (__syscall_error): Access gprel errno if RTLD_PRIVATE_ERRNO or __thread __libc_errno/errno if USE___THREAD. nptl/ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SYSDEP_CANCEL_ERRNO, SYSDEP_CANCEL_ERROR): Define. (PSEUDO): Use it. --- libc/include/libc-symbols.h.jj 2004-03-11 11:10:07.000000000 +0100 +++ libc/include/libc-symbols.h 2004-04-23 06:48:31.080058057 +0200 @@ -749,11 +749,17 @@ for linking") # define libc_hidden_builtin_def(name) libc_hidden_def (name) # define libc_hidden_builtin_weak(name) libc_hidden_weak (name) # define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name) +# ifdef __ASSEMBLER__ +# define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name) +# endif #else # define libc_hidden_builtin_proto(name, attrs...) # define libc_hidden_builtin_def(name) # define libc_hidden_builtin_weak(name) # define libc_hidden_builtin_ver(local, name) +# ifdef __ASSEMBLER__ +# define HIDDEN_BUILTIN_JUMPTARGET(name) JUMPTARGET(name) +# endif #endif /* Get some dirty hacks. */ --- libc/sysdeps/ia64/bcopy.S.jj 2004-04-22 22:39:24.000000000 +0200 +++ libc/sysdeps/ia64/bcopy.S 2004-04-23 06:49:03.761201170 +0200 @@ -6,5 +6,5 @@ ENTRY(bcopy) mov in0 = in1 ;; mov in1 = r8 - br.cond.sptk.many HIDDEN_JUMPTARGET(memmove) + br.cond.sptk.many HIDDEN_BUILTIN_JUMPTARGET(memmove) END(bcopy) --- libc/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h.jj 2004-04-23 06:40:20.000000000 -0400 +++ libc/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h 2004-04-23 07:47:37.000000000 -0400 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -27,9 +27,58 @@ # undef PSEUDO -#ifndef USE_DL_SYSINFO +# ifdef USE___THREAD +# ifndef NOT_IN_libc +# define SYSDEP_CANCEL_ERRNO __libc_errno +# else +# define SYSDEP_CANCEL_ERRNO errno +# endif +# define SYSDEP_CANCEL_ERROR(args) \ +.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \ + .align 32; \ + .proc __syscall_error_##args; \ + .global __syscall_error_##args; \ + .hidden __syscall_error_##args; \ + .size __syscall_error_##args, 64; \ +__syscall_error_##args: \ + .prologue; \ + .regstk args, 5, args, 0; \ + .save ar.pfs, loc0; \ + .save rp, loc1; \ + .body; \ + addl loc4 = @ltoff(@tprel(SYSDEP_CANCEL_ERRNO)), gp;; \ + ld8 loc4 = [loc4]; \ + mov rp = loc1;; \ + mov r8 = -1; \ + add loc4 = loc4, r13;; \ + st4 [loc4] = loc3; \ + mov ar.pfs = loc0 +# else +# define SYSDEP_CANCEL_ERROR(args) \ +.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \ + .align 32; \ + .proc __syscall_error_##args; \ + .global __syscall_error_##args; \ + .hidden __syscall_error_##args; \ + .size __syscall_error_##args, 64; \ +__syscall_error_##args: \ + .prologue; \ + .regstk args, 5, args, 0; \ + .save ar.pfs, loc0; \ + .save rp, loc1; \ + .body; \ + mov loc4 = r1;; \ + br.call.sptk.many b0 = __errno_location;; \ + st4 [r8] = loc3; \ + mov r1 = loc4; \ + mov rp = loc1; \ + mov r8 = -1; \ + mov ar.pfs = loc0 +# endif -# define PSEUDO(name, syscall_name, args) \ +# ifndef USE_DL_SYSINFO + +# define PSEUDO(name, syscall_name, args) \ .text; \ ENTRY (name) \ adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \ @@ -71,29 +120,11 @@ __GC_##name: \ .Lpseudo_end: \ ret; \ .endp __GC_##name; \ -.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \ - .align 32; \ - .proc __syscall_error_##args; \ - .global __syscall_error_##args; \ - .hidden __syscall_error_##args; \ - .size __syscall_error_##args, 64; \ -__syscall_error_##args: \ - .prologue; \ - .regstk args, 5, args, 0; \ - .save ar.pfs, loc0; \ - .save rp, loc1; \ - .body; \ - mov loc4 = r1;; \ - br.call.sptk.many b0 = __errno_location;; \ - st4 [r8] = loc3; \ - mov r1 = loc4; \ - mov rp = loc1; \ - mov r8 = -1; \ - mov ar.pfs = loc0 + SYSDEP_CANCEL_ERROR(args) -#else /* USE_DL_SYSINFO */ +# else /* USE_DL_SYSINFO */ -# define PSEUDO(name, syscall_name, args) \ +# define PSEUDO(name, syscall_name, args) \ .text; \ ENTRY (name) \ .prologue; \ @@ -146,30 +177,12 @@ __GC_##name: \ .Lpseudo_end: \ ret; \ .endp __GC_##name; \ -.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \ - .align 32; \ - .proc __syscall_error_##args; \ - .global __syscall_error_##args; \ - .hidden __syscall_error_##args; \ - .size __syscall_error_##args, 64; \ -__syscall_error_##args: \ - .prologue; \ - .regstk args, 5, args, 0; \ - .save ar.pfs, loc0; \ - .save rp, loc1; \ - .body; \ - mov loc4 = r1;; \ - br.call.sptk.many b0 = __errno_location;; \ - st4 [r8] = loc3; \ - mov r1 = loc4; \ - mov rp = loc1; \ - mov r8 = -1; \ - mov ar.pfs = loc0 + SYSDEP_CANCEL_ERROR(args) -#endif /* USE_DL_SYSINFO */ +# endif /* USE_DL_SYSINFO */ -#undef PSEUDO_END -#define PSEUDO_END(name) .endp +# undef PSEUDO_END +# define PSEUDO_END(name) .endp # ifdef IS_IN_libpthread # define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel @@ -184,14 +197,14 @@ __syscall_error_##args: \ # error Unsupported library # endif -#define COPY_ARGS_0 /* Nothing */ -#define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0; -#define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1; -#define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2; -#define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3; -#define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4; -#define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5; -#define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6; +# define COPY_ARGS_0 /* Nothing */ +# define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0; +# define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1; +# define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2; +# define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3; +# define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4; +# define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5; +# define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6; # ifndef __ASSEMBLER__ # define SINGLE_THREAD_P \ --- libc/sysdeps/unix/sysv/linux/ia64/sysdep.S.jj 2003-02-27 04:32:40.000000000 -0500 +++ libc/sysdeps/unix/sysv/linux/ia64/sysdep.S 2004-04-23 07:59:53.000000000 -0400 @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger-Tang . @@ -19,9 +19,34 @@ #include #include +#include ENTRY(__syscall_error) -#ifdef _LIBC_REENTRANT +#if RTLD_PRIVATE_ERRNO + /* + * Note that the gp has to be set properly for this to work. + * As long as all syscalls are in the same load unit + * (executable or shared library) as this routine, we should + * be fine. Otherwise, we would have to first load the global + * pointer register from __gp. + */ + addl r2=@gprel(errno),gp + ;; + st4 [r2]=r8 + mov r8=-1 +#elif defined USE___THREAD +# ifndef NOT_IN_libc +# define SYSCALL_ERROR_ERRNO __libc_errno +# else +# define SYSCALL_ERROR_ERRNO errno +# endif + addl r2=@ltoff(@tprel(SYSCALL_ERROR_ERRNO)), gp;; + ld8 r2=[r2] + mov r3=r8;; + mov r8=-1 + add r2=r2,r13;; + st4 [r2]=r3 +#elif defined _LIBC_REENTRANT .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(0) alloc r33=ar.pfs, 0, 4, 0, 0 mov r32=rp Jakub