This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Move __libc_fini_array into a separate file.


On Jun  4 11:31, Jeff Johnston wrote:
> On 06/03/2010 06:57 PM, Mark Mitchell wrote:
> >Jeff Johnston wrote:
> >>What calls the new static routine register_fini??  I don't see anything
> >>using it in this patch.
> >
> >>>+static void
> >>>+register_fini(void) __attribute__((constructor (0)));
> >
> >It's a constructor function.
> >
> >Thanks,
> >
> 
> Ah.  Patch applied.

This patch breaks building Cygwin.  When building from scratch, I'm
getting this error message now:

  Creating library file: cygdll.a
  /ext/build/cygwin/src/i686-pc-cygwin/newlib/libc/libc.a(lib_a-__call_atexit.o): 
  In function `register_fini':
  /home/corinna/src/cygwin/src/newlib/libc/stdlib/__call_atexit.c:49: undefined re
  ference to `__fini'
  collect2: ld returned 1 exit status

The problem is this.  In the former code, newlib only referenced _fini
if HAVE_INITFINI_ARRAY was defined.  If it wasn't defined, none of the
code in libc/misc/init.c was complied in.

Now, with the new code, _fini() is *always* referenced, even on systems
which don't define HAVE_INITFINI_ARRAY:

  libc/stdlib/__call_atexit.c:

    static void
    register_fini(void)
    {
      if (&__libc_fini) {
    #ifdef HAVE_INITFINI_ARRAY
	extern void __libc_fini_array (void);
	atexit (__libc_fini_array);
    #else
	extern void _fini (void);
	atexit (_fini);
    #endif
      }
    }
     
AFAICS, the #else part of the conditional code just has to go away.

However, I'm not an expert in this stuff, so what do other's think
is the right solution?


Corinna


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