[patch] Move __libc_fini_array into a separate file.

Corinna Vinschen vinschen@redhat.com
Tue Jun 8 18:49:00 GMT 2010

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
  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:


    static void
      if (&__libc_fini) {
	extern void __libc_fini_array (void);
	atexit (__libc_fini_array);
	extern void _fini (void);
	atexit (_fini);
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?


More information about the Newlib mailing list