From: "H. J. Lu" <hjl@lucon.org>
To: davidm@hpl.hp.com
Cc: Roland McGrath <roland@frob.com>, libc-hacker@sources.redhat.com
Subject: Re: patch to make init_array work (3nd version)
Date: Wed, 27 Nov 2002 15:10:00 -0000 [thread overview]
Message-ID: <20021127150958.A15921@lucon.org> (raw)
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
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 <davidm@hpl.hp.com>
>
> * 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.
next prev parent reply other threads:[~2002-11-27 23:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-08 11:34 patch to make init_array work (2nd version; resend) Roland McGrath
2002-11-08 11:38 ` David Mosberger
2002-11-27 14:35 ` patch to make init_array work (3nd version) David Mosberger
2002-11-27 15:10 ` H. J. Lu [this message]
2002-11-27 15:34 ` David Mosberger
2002-12-09 10:52 ` Roland McGrath
2002-12-09 13:36 ` David Mosberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021127150958.A15921@lucon.org \
--to=hjl@lucon.org \
--cc=davidm@hpl.hp.com \
--cc=libc-hacker@sources.redhat.com \
--cc=roland@frob.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).