This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
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.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |