From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3182 invoked by alias); 27 Nov 2002 23:10:02 -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 3165 invoked from network); 27 Nov 2002 23:10:01 -0000 Received: from unknown (HELO sccrmhc01.attbi.com) (204.127.202.61) by sources.redhat.com with SMTP; 27 Nov 2002 23:10:01 -0000 Received: from lucon.org (12-234-88-146.client.attbi.com[12.234.88.146]) by sccrmhc01.attbi.com (sccrmhc01) with ESMTP id <2002112723100000100q9aibe>; Wed, 27 Nov 2002 23:10:00 +0000 Received: by lucon.org (Postfix, from userid 1000) id 3A5B22C84F; Wed, 27 Nov 2002 15:09:58 -0800 (PST) Date: Wed, 27 Nov 2002 15:10:00 -0000 From: "H. J. Lu" To: davidm@hpl.hp.com Cc: Roland McGrath , libc-hacker@sources.redhat.com Subject: Re: patch to make init_array work (3nd version) Message-ID: <20021127150958.A15921@lucon.org> References: <200211081934.gA8JYVB05781@magilla.sf.frob.com> <15845.18613.38095.974630@napali.hpl.hp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <15845.18613.38095.974630@napali.hpl.hp.com>; from davidm@napali.hpl.hp.com on Wed, Nov 27, 2002 at 02:35:33PM -0800 X-SW-Source: 2002-11/txt/msg00069.txt.bz2 On Wed, Nov 27, 2002 at 02:35:33PM -0800, David Mosberger wrote: > Below is a revised patch to get init_array working. This is basically > what Richard suggested. Roland, you suggested that the new routines > in csu/init.c could be "static", but I don't see how this would work > given that the routines need to be accessed from start.S. > > A problem with this new approach is that the preinit_array functions > need to be executed by csu/init.c only for statically linked programs. > I don't know of a good way to detect this inside init.c, so I changed > the init callback to take an extra argument (which will be ignored on > platforms that don't support init_array). > > To be honest, HJ's original solution seems nicer to me (e.g., doesn't > require changes to platform-specific code), though I see the point > about additional relocs. I am not sure how this approach will work. If I get it right, __libc_do_init_calls and __libc_do_fini_calls are defined in executables. But they are only available when executables are linked against with the new glibc. For the existing executables, there are no __libc_do_init_calls nor __libc_do_fini_calls. That is why my original solution has #ifdef HAVE_INITFINI_ARRAY # ifdef SHARED extern void __libc_init_array (void) __attribute__ ((weak)); extern void __libc_fini_array (void) __attribute__ ((weak)); # else extern void __libc_preinit_array (void); extern void __libc_init_array (void); extern void __libc_fini_array (void); # endif #endif ... #ifdef HAVE_INITFINI_ARRAY # ifdef SHARED if (__libc_fini_array) # endif __cxa_atexit ((void (*) (void *)) __libc_fini_array, NULL, NULL); # ifndef SHARED __libc_preinit_array (); # endif #endif which will work with all exutables. > > Note: the patch below makes init_array working on ia64 only. Other > platforms would have to make the analogous (trivial) change to > start.S. > > In terms of testing, "make check" passed, so the basics seem to be > right. > > --david > > ChangeLog > > 2002-11-27 David Mosberger > > * sysdeps/generic/libc-start.c (__libc_start_main): Declare > INIT callback as taking an integer argument indicating whether > program is a statically-linked executable. Update call-site > accordingly. > > * elf/Makefile (tests): Re-enable init_array tests. > > * csu/init.c (__preinit_array_start): Declare. > (__preinit_array_end): Ditto. > (__init_array_start): Ditto. > (__init_array_end): Ditto. > (__fini_array_start): Ditto. > (__fini_array_end): Ditto. > (_init): Declare as an external function. > (_fini): Ditto. > (__libc_do_init_calls): New function. > (__libc_do_fini_calls): Ditto. > You missed the ChangeLog entry for sysdeps/ia64/elf/start.S. H.J.