* libc/stdlib/__call_atexit.c (__libc_fini): Declare. (register_fini): New function. * libc/misc/init.c (_fini): Remove. (__libc_fini_array): Likewise. * libc/misc/fini.c: New file. * libc/misc/Makefile.am (LIB_SOURCES): Add fini.c. * libc/misc/Makefile.in: Regenerate.
* libc/misc/init.c (__libc_fini_array): Process fini_array in reverse order as compliant with the ELF specification.
* configure.in: Add test for .init_array. * configure: Regenerate. * newlib.hin: Add HAVE_INITFINI_ARRAY. * libc/misc/Makefile.am: Add init.c * libc/misc/Makefile.in: Regenerate. * libc/misc/init.c: New file. * libc/sys/arm/crt0.S: Call __libc_{init,fini}_array instead of _init/_fini if they exist.