From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13264 invoked by alias); 20 Mar 2007 12:36:02 -0000 Received: (qmail 13236 invoked by uid 22791); 20 Mar 2007 12:36:01 -0000 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.31) with ESMTP; Tue, 20 Mar 2007 12:35:50 +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 l2KCe24w015463; Tue, 20 Mar 2007 13:40:02 +0100 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id l2KCdxJv015414; Tue, 20 Mar 2007 13:39:59 +0100 Date: Tue, 20 Mar 2007 12:36:00 -0000 From: Jakub Jelinek To: Steven Munroe , Ulrich Drepper Cc: Roland McGrath , Richard Henderson , libc-hacker@sourceware.org Subject: [PATCH] Fix up ppc __cache_line_size Message-ID: <20070320123958.GW1826@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek References: <20070313201706.8D8351801C5@magilla.sf.frob.com> <45F71009.8020705@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45F71009.8020705@us.ibm.com> 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: 2007-03/txt/msg00030.txt.bz2 On Tue, Mar 13, 2007 at 03:56:41PM -0500, Steven Munroe wrote: > Roland McGrath wrote: > >> +#ifdef DL_PLATFORM_AUXV > >> + DL_PLATFORM_AUXV > >> +#endif > >> > > > > This looks ok to me, but make it # ifdef there inside another #ifdef. > > > > This will also affect powerpc, which AFAICT was also failing to set its > > __cache_line_size in static programs. It looks to me like that will be fine. > > > > > hmmm looks like powerpc needs a > sysdeps/unix/sysv/linux/powerpc/dl-support.c to define DL_PLATFORM_AUXV > and include /elf/dl-support.c ? IMHO there is no reason to use weak_extern for __cache_line_size. Code to check the weak references and only conditionally set it is certainly bigger than just defining the hidden variables in libc-start.c and dl-sysdep.c. Additionally, if you build power4+ optimized ld.so, __cache_line_size isn't defined at all and thus dl-machine.c will never use it. The following patch works for me (though only tested with binutils and gcc that support HAVE_ASM_PPC_REL16 (so __cache_line_size references don't need runtime relocation). Not sure if we still support older binutils. 2007-03-20 Jakub Jelinek * sysdeps/unix/sysv/linux/powerpc/libc-start.c (__cache_line_size): Define the variable here. Add attribute_hidden, remove weak_extern. (__libc_start_main): Set __cache_line_size unconditionally. * sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c (__cache_line_size): Define the variable here. Add attribute_hidden, remove weak_extern. (DL_PLATFORM_AUXV): Set __cache_line_size unconditionally. * sysdeps/powerpc/powerpc32/dl-machine.c (__cache_line_size): Remove weak_extern, add attribute_hidden. (__elf_machine_runtime_setup): Assume __cache_line_size is always defined in ld.so. * sysdeps/powerpc/powerpc32/memset.S (__cache_line_size): Remove definition. * sysdeps/powerpc/powerpc64/memset.S (__cache_line_size): Likewise. --- libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c.jj 2005-12-30 08:30:11.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c 2007-03-20 11:56:13.000000000 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1998,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc. +/* Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2007 + 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 @@ -22,8 +23,7 @@ #include #include -extern int __cache_line_size; -weak_extern (__cache_line_size) +int __cache_line_size attribute_hidden; /* The main work is done in the generic function. */ #define LIBC_START_MAIN generic_start_main #define LIBC_START_DISABLE_INLINE @@ -113,11 +113,7 @@ int switch (av->a_type) { case AT_DCACHEBSIZE: - { - int *cls = &__cache_line_size; - if (cls != NULL) - *cls = av->a_un.a_val; - } + __cache_line_size = av->a_un.a_val; break; } #ifdef SHARED --- libc/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c.jj 2006-01-11 16:55:32.000000000 +0100 +++ libc/sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c 2007-03-20 11:57:19.000000000 +0100 @@ -1,5 +1,6 @@ /* Operating system support for run-time dynamic linker. Linux/PPC version. - Copyright (C) 1997, 1998, 2001, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2001, 2003, 2006, 2007 + 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 @@ -21,8 +22,7 @@ #include #include -extern int __cache_line_size; -weak_extern (__cache_line_size) +int __cache_line_size attribute_hidden; /* Scan the Aux Vector for the "Data Cache Block Size" entry. If found verify that the static extern __cache_line_size is defined by checking @@ -30,12 +30,8 @@ weak_extern (__cache_line_size) value to __cache_line_size. */ #define DL_PLATFORM_AUXV \ case AT_DCACHEBSIZE: \ - { \ - int *cls = & __cache_line_size; \ - if (cls != NULL) \ - *cls = av->a_un.a_val; \ - } \ - break; + __cache_line_size = av->a_un.a_val; \ + break; #ifndef __ASSUME_STD_AUXV --- libc/sysdeps/powerpc/powerpc64/memset.S.jj 2005-06-06 14:36:11.000000000 +0200 +++ libc/sysdeps/powerpc/powerpc64/memset.S 2007-03-20 11:59:30.000000000 +0100 @@ -1,5 +1,6 @@ /* Optimized memset implementation for PowerPC64. - Copyright (C) 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2000, 2002, 2003, 2007 + 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 @@ -21,12 +22,6 @@ #include #include -/* Define a global static that can hold the cache line size. The - assumption is that startup code will access the "aux vector" to - to obtain the value set by the kernel and store it into this - variable. */ - .globl __cache_line_size - .lcomm __cache_line_size,4,4 .section ".toc","aw" .LC0: .tc __cache_line_size[TC],__cache_line_size --- libc/sysdeps/powerpc/powerpc32/memset.S.jj 2005-06-22 18:34:22.000000000 +0200 +++ libc/sysdeps/powerpc/powerpc32/memset.S 2007-03-20 12:01:36.000000000 +0100 @@ -1,5 +1,5 @@ /* Optimized memset implementation for PowerPC. - Copyright (C) 1997, 1999, 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2000, 2003, 2007 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 @@ -21,14 +21,6 @@ #include #include -/* Define a global static that can hold the cache line size. The - assumption is that startup code will access the "aux vector" to - to obtain the value set by the kernel and store it into this - variable. */ - - .globl __cache_line_size - .lcomm __cache_line_size,4,4 - /* __ptr_t [r3] memset (__ptr_t s [r3], int c [r4], size_t n [r5])); Returns 's'. --- libc/sysdeps/powerpc/powerpc32/dl-machine.c.jj 2006-11-28 11:25:24.000000000 +0100 +++ libc/sysdeps/powerpc/powerpc32/dl-machine.c 2007-03-20 12:06:30.000000000 +0100 @@ -26,10 +26,9 @@ #include #include -/* The value __cache_line_size is defined in memset.S and is initialised +/* The value __cache_line_size is defined in dl-sysdep.c and is initialised by _dl_sysdep_start via DL_PLATFORM_INIT. */ -extern int __cache_line_size; -weak_extern (__cache_line_size) +extern int __cache_line_size attribute_hidden; /* Because ld.so is now versioned, these functions can be in their own file; no relocations need to be done to call them. @@ -318,15 +317,9 @@ __elf_machine_runtime_setup (struct link /* Default minimum 4 words per cache line. */ int line_size_words = 4; - /* Don't try this until ld.so has relocated itself! */ - int *line_size_ptr = &__cache_line_size; - if (lazy && line_size_ptr != NULL) - { - /* Verify that __cache_line_size is defined and set. */ - if (*line_size_ptr != 0) - /* Convert bytes to words. */ - line_size_words = *line_size_ptr / 4; - } + if (lazy && __cache_line_size != 0) + /* Convert bytes to words. */ + line_size_words = __cache_line_size / 4; size_modified = lazy ? rel_offset_words : 6; for (i = 0; i < size_modified; i += line_size_words) Jakub