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]

Re: libanl + atexit + more


On Mon, Mar 05, 2001 at 09:51:37PM +0100, Andreas Jaeger wrote:
> Andreas Jaeger <aj@suse.de> writes:
> 
> > Ulrich Drepper <drepper@redhat.com> writes:
> > 
> > > Second, I haven't gotten any comments on the atexit() implementation
> > > changes I made.  They are so non-obvious that I thought the one or
> > > other would comment.  The good thing is that this implementation
> > > should be very robust.  The bad thing is that old programs cannot be
> > > fixed, everything (means DSOs) has to be relinked (if they have this
> > > problem which is fortunately rare).  I don't think this is a problem.
> > > Note that today (until sometime next week :-) this atexit()
> > > implementation is not Unix conforming.  Unix currently forbids this
> > > behavior (this means the registered functions are called at dlclose()
> > > time).  I've filed an defect report which will be handled next week.
> > 
> > make check fails now for me:
> > 
> > GCONV_PATH=/builds/glibc/main-gcc-2.95/iconvdata LC_ALL=C   /builds/glibc/main-gcc-2.95/elf/ld-linux.so.2 --library-path /builds/glibc/main-gcc-2.95:/builds/glibc/main-gcc-2.95/math:/builds/glibc/main-gcc-2.95/elf:/builds/glibc/main-gcc-2.95/dlfcn:/builds/glibc/main-gcc-2.95/nss:/builds/glibc/main-gcc-2.95/nis:/builds/glibc/main-gcc-2.95/rt:/builds/glibc/main-gcc-2.95/resolv:/builds/glibc/main-gcc-2.95/crypt:/builds/glibc/main-gcc-2.95/linuxthreads /builds/glibc/main-gcc-2.95/dlfcn/tstcxaatexit  > /builds/glibc/main-gcc-2.95/dlfcn/tstcxaatexit.out
> > make[2]: *** [/builds/glibc/main-gcc-2.95/dlfcn/tstcxaatexit.out] Error 1
> > 
> > gromit:/builds/glibc/main-gcc-2.95:[0]$ cat dlfcn/tstcxaatexit.out 
> > cannot open "modcxaatexit.so": /builds/glibc/main-gcc-2.95/dlfcn/modcxaatexit.so: undefined symbol: __dso_handle

This one can be compiled with something like:

--- libc/dlfcn/modcxaatexit.c.jj	Mon Feb 26 18:41:22 2001
+++ libc/dlfcn/modcxaatexit.c	Tue Mar  6 16:34:53 2001
@@ -33,7 +33,7 @@ fluffy (void *p)
 void
 bar (void *p)
 {
-  extern void *__dso_handle;
+  extern void *__dso_handle __attribute__ ((__weak__));
   printf ("This is %s\n", __FUNCTION__);
-  __cxa_atexit (fluffy, p, __dso_handle);
+  __cxa_atexit (fluffy, p, &__dso_handle ? __dso_handle : NULL);
 }

(but the test will fail anyway).
> > 
> > This is with gcc 2.95.2.  With a 3.0 pre release I get a segmentation
> > fault, I'll send details tomorrow.
> 
> It's not tomorrow ;-) but here's the failure:
> 
> gromit:/usr/src/cvs/libc/dlfcn:[0]$ GCONV_PATH=/builds/glibc/20010106-gcc-2.97.test/iconvdata LC_ALL=C   /builds/glibc/20010106-gcc-2.97.test/elf/ld-linux.so.2 --library-path /builds/glibc/20010106-gcc-2.97.test:/builds/glibc/20010106-gcc-2.97.test/math:/builds/glibc/20010106-gcc-2.97.test/elf:/builds/glibc/20010106-gcc-2.97.test/dlfcn:/builds/glibc/20010106-gcc-2.97.test/nss:/builds/glibc/20010106-gcc-2.97.test/nis:/builds/glibc/20010106-gcc-2.97.test/rt:/builds/glibc/20010106-gcc-2.97.test/resolv:/builds/glibc/20010106-gcc-2.97.test/crypt:/builds/glibc/20010106-gcc-2.97.test/linuxthreads /builds/glibc/20010106-gcc-2.97.test/dlfcn/tstcxaatexit
> This is bar
> module unload didn't change `v'
> Segmentation fault

But this one is IMHO more problematic. Initially I thought it is just that
libc_nonshared.a is not being dragged into DSOs built during glibc make, so
I have hacked up Makerules so that it drags in libc_nonshared.a and libc.so
if libc.so was requested (and did this outside of -Wl,--(no-)whole-archive
pair), but that did not fix things up, since gcc's crtstuff has this in:

/* This is a kludge. The i386 GNU/Linux dynamic linker needs ___brk_addr,
   __environ and atexit (). We have to make sure they are in the .dynsym
   section. We accomplish it by making a dummy call here. This
   code is never reached.  */

#if defined(__linux__) && defined(__PIC__) && defined(__i386__)
  {
    extern void *___brk_addr;
    extern char **__environ;

    ___brk_addr = __environ;
    atexit (0);
  }
#endif

and so atexit ends up unversioned and undefined.
Perhaps we could change the order in libc.so linker script to
libc_nonshared.a libc.so and change atexit in glibc back to normal symbol
again, so that it catches up crtendS.o which comes last (well, before crtn.o
but there is just one for both shared and non-shared).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]