2013-07-02 Joey Ye <joey.ye@arm.com>
Lite exit support. * README: Add information about lite-exit. * acconfig.h (_LITE_EXIT): New macro. * configure.in (enable-lite-exit): New option. (_LITE_EXIT): Define new macro. * configure: Regenerated. * newlib.hin (_LITE_EXIT): New macro. * libc/stdlib/__atexit.c [_LITE_EXIT]: Add dummy explicit reference to __call_exitprocs. * libc/stdlib/cxa_atexit.c [_LITE_EXIT]: Make __register_exitproc a weak reference. * libc/stdlib/exit.c (exit)[_LITE_EXIT]: Remove TWS and weakly reference __call_exitprocs.
This commit is contained in:
parent
a838011d07
commit
e2ac49d3d7
|
@ -1,3 +1,19 @@
|
||||||
|
2013-07-02 Joey Ye <joey.ye@arm.com>
|
||||||
|
|
||||||
|
Lite exit support.
|
||||||
|
* README: Add information about lite-exit.
|
||||||
|
* acconfig.h (_LITE_EXIT): New macro.
|
||||||
|
* configure.in (enable-lite-exit): New option.
|
||||||
|
(_LITE_EXIT): Define new macro.
|
||||||
|
* configure: Regenerated.
|
||||||
|
* newlib.hin (_LITE_EXIT): New macro.
|
||||||
|
* libc/stdlib/__atexit.c [_LITE_EXIT]: Add dummy explicit
|
||||||
|
reference to __call_exitprocs.
|
||||||
|
* libc/stdlib/cxa_atexit.c [_LITE_EXIT]: Make __register_exitproc a
|
||||||
|
weak reference.
|
||||||
|
* libc/stdlib/exit.c (exit)[_LITE_EXIT]: Remove TWS and weakly reference
|
||||||
|
__call_exitprocs.
|
||||||
|
|
||||||
2013-07-02 Jeff Johnston <jjohnstn@redhat.com>
|
2013-07-02 Jeff Johnston <jjohnstn@redhat.com>
|
||||||
|
|
||||||
* libc/include/sys/reent.h: Fix typo in comment.
|
* libc/include/sys/reent.h: Fix typo in comment.
|
||||||
|
|
|
@ -361,6 +361,11 @@ One feature can be enabled by specifying `--enable-FEATURE=yes' or
|
||||||
Disable newlib from supplying syscalls.
|
Disable newlib from supplying syscalls.
|
||||||
Enabled by default.
|
Enabled by default.
|
||||||
|
|
||||||
|
`--enable-lite-exit'
|
||||||
|
Enable lite exit, a size-reduced implementation of exit that doesn't
|
||||||
|
invoke clean-up functions such as _fini or global destructors.
|
||||||
|
Disabled by default.
|
||||||
|
|
||||||
Running the Testsuite
|
Running the Testsuite
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
/* Define if unbuffered stream file optimization is supported. */
|
/* Define if unbuffered stream file optimization is supported. */
|
||||||
#undef _UNBUF_STREAM_OPT
|
#undef _UNBUF_STREAM_OPT
|
||||||
|
|
||||||
|
/* Define if enable lite version of exit. */
|
||||||
|
#undef _LITE_EXIT
|
||||||
|
|
||||||
@BOTTOM@
|
@BOTTOM@
|
||||||
/*
|
/*
|
||||||
* Iconv encodings enabled ("to" direction)
|
* Iconv encodings enabled ("to" direction)
|
||||||
|
|
|
@ -794,6 +794,7 @@ enable_newlib_fseek_optimization
|
||||||
enable_newlib_wide_orient
|
enable_newlib_wide_orient
|
||||||
enable_newlib_nano_malloc
|
enable_newlib_nano_malloc
|
||||||
enable_newlib_unbuf_stream_opt
|
enable_newlib_unbuf_stream_opt
|
||||||
|
enable_lite_exit
|
||||||
enable_multilib
|
enable_multilib
|
||||||
enable_target_optspace
|
enable_target_optspace
|
||||||
enable_malloc_debugging
|
enable_malloc_debugging
|
||||||
|
@ -1462,6 +1463,7 @@ Optional Features:
|
||||||
--disable-newlib-wide-orient Turn off wide orientation in streamio
|
--disable-newlib-wide-orient Turn off wide orientation in streamio
|
||||||
--enable-newlib-nano-malloc use small-footprint nano-malloc implementation
|
--enable-newlib-nano-malloc use small-footprint nano-malloc implementation
|
||||||
--disable-newlib-unbuf-stream-opt disable unbuffered stream optimization in streamio
|
--disable-newlib-unbuf-stream-opt disable unbuffered stream optimization in streamio
|
||||||
|
--enable-lite-exit enable light weight exit
|
||||||
--enable-multilib build many library versions (default)
|
--enable-multilib build many library versions (default)
|
||||||
--enable-target-optspace optimize for space
|
--enable-target-optspace optimize for space
|
||||||
--enable-malloc-debugging indicate malloc debugging requested
|
--enable-malloc-debugging indicate malloc debugging requested
|
||||||
|
@ -2425,6 +2427,19 @@ else
|
||||||
newlib_unbuf_stream_opt=yes
|
newlib_unbuf_stream_opt=yes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check whether --enable-lite-exit was given.
|
||||||
|
if test "${enable_lite_exit+set}" = set; then :
|
||||||
|
enableval=$enable_lite_exit; if test "${lite_exit+set}" != set; then
|
||||||
|
case "${enableval}" in
|
||||||
|
yes) lite_exit=yes ;;
|
||||||
|
no) lite_exit=no ;;
|
||||||
|
*) as_fn_error $? "bad value ${enableval} for lite-exit option" "$LINENO" 5 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
lite_exit=no
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Make sure we can run config.sub.
|
# Make sure we can run config.sub.
|
||||||
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
|
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
|
||||||
|
@ -11725,7 +11740,7 @@ else
|
||||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||||
lt_status=$lt_dlunknown
|
lt_status=$lt_dlunknown
|
||||||
cat > conftest.$ac_ext <<_LT_EOF
|
cat > conftest.$ac_ext <<_LT_EOF
|
||||||
#line 11698 "configure"
|
#line 11743 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
#if HAVE_DLFCN_H
|
#if HAVE_DLFCN_H
|
||||||
|
@ -11831,7 +11846,7 @@ else
|
||||||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||||
lt_status=$lt_dlunknown
|
lt_status=$lt_dlunknown
|
||||||
cat > conftest.$ac_ext <<_LT_EOF
|
cat > conftest.$ac_ext <<_LT_EOF
|
||||||
#line 11804 "configure"
|
#line 11849 "configure"
|
||||||
#include "confdefs.h"
|
#include "confdefs.h"
|
||||||
|
|
||||||
#if HAVE_DLFCN_H
|
#if HAVE_DLFCN_H
|
||||||
|
@ -12341,6 +12356,13 @@ _ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "${lite_exit}" = "yes"; then
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define _LITE_EXIT 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if test "x${iconv_encodings}" != "x" \
|
if test "x${iconv_encodings}" != "x" \
|
||||||
|| test "x${iconv_to_encodings}" != "x" \
|
|| test "x${iconv_to_encodings}" != "x" \
|
||||||
|
|
|
@ -181,6 +181,19 @@ AC_ARG_ENABLE(newlib-unbuf-stream-opt,
|
||||||
esac
|
esac
|
||||||
fi], [newlib_unbuf_stream_opt=yes])dnl
|
fi], [newlib_unbuf_stream_opt=yes])dnl
|
||||||
|
|
||||||
|
dnl Support --enable-lite-exit
|
||||||
|
dnl Lite exit is a size-reduced implementation of exit that doesn't invoke
|
||||||
|
dnl clean-up functions such as _fini or global destructors.
|
||||||
|
AC_ARG_ENABLE(lite-exit,
|
||||||
|
[ --enable-lite-exit enable light weight exit],
|
||||||
|
[if test "${lite_exit+set}" != set; then
|
||||||
|
case "${enableval}" in
|
||||||
|
yes) lite_exit=yes ;;
|
||||||
|
no) lite_exit=no ;;
|
||||||
|
*) AC_MSG_ERROR(bad value ${enableval} for lite-exit option) ;;
|
||||||
|
esac
|
||||||
|
fi], [lite_exit=no])dnl
|
||||||
|
|
||||||
NEWLIB_CONFIGURE(.)
|
NEWLIB_CONFIGURE(.)
|
||||||
|
|
||||||
dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
|
dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
|
||||||
|
@ -390,6 +403,10 @@ if test "${newlib_unbuf_stream_opt}" = "yes"; then
|
||||||
AC_DEFINE_UNQUOTED(_UNBUF_STREAM_OPT)
|
AC_DEFINE_UNQUOTED(_UNBUF_STREAM_OPT)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "${lite_exit}" = "yes"; then
|
||||||
|
AC_DEFINE_UNQUOTED(_LITE_EXIT)
|
||||||
|
fi
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Parse --enable-newlib-iconv-encodings option argument
|
dnl Parse --enable-newlib-iconv-encodings option argument
|
||||||
dnl
|
dnl
|
||||||
|
|
|
@ -1,5 +1,35 @@
|
||||||
/*
|
/*
|
||||||
* Common routine to implement atexit-like functionality.
|
* Common routine to implement atexit-like functionality.
|
||||||
|
*
|
||||||
|
* This is also the key function to be configured as lite exit, a size-reduced
|
||||||
|
* implementation of exit that doesn't invoke clean-up functions such as _fini
|
||||||
|
* or global destructors.
|
||||||
|
*
|
||||||
|
* Default (without lite exit) call graph is like:
|
||||||
|
* _start -> atexit -> __register_exitproc
|
||||||
|
* _start -> __libc_init_array -> __cxa_atexit -> __register_exitproc
|
||||||
|
* on_exit -> __register_exitproc
|
||||||
|
* _start -> exit -> __call_exitprocs
|
||||||
|
*
|
||||||
|
* Here an -> means arrow tail invokes arrow head. All invocations here
|
||||||
|
* are non-weak reference in current newlib/libgloss.
|
||||||
|
*
|
||||||
|
* Lite exit makes some of above calls as weak reference, so that size expansive
|
||||||
|
* functions __register_exitproc and __call_exitprocs may not be linked. These
|
||||||
|
* calls are:
|
||||||
|
* _start w-> atexit
|
||||||
|
* __cxa_atexit w-> __register_exitproc
|
||||||
|
* exit w-> __call_exitprocs
|
||||||
|
*
|
||||||
|
* Lite exit also makes sure that __call_exitprocs will be referenced as non-weak
|
||||||
|
* whenever __register_exitproc is referenced as non-weak.
|
||||||
|
*
|
||||||
|
* Thus with lite exit libs, a program not explicitly calling atexit or on_exit
|
||||||
|
* will escape from the burden of cleaning up code. A program with atexit or on_exit
|
||||||
|
* will work consistently to normal libs.
|
||||||
|
*
|
||||||
|
* Lite exit is enabled with --enable-lite-exit, and is controlled with macro
|
||||||
|
* _LITE_EXIT.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -11,6 +41,12 @@
|
||||||
/* Make this a weak reference to avoid pulling in malloc. */
|
/* Make this a weak reference to avoid pulling in malloc. */
|
||||||
void * malloc(size_t) _ATTRIBUTE((__weak__));
|
void * malloc(size_t) _ATTRIBUTE((__weak__));
|
||||||
|
|
||||||
|
#ifdef _LITE_EXIT
|
||||||
|
/* As __call_exitprocs is weak reference in lite exit, make a
|
||||||
|
non-weak reference to it here. */
|
||||||
|
const void * __atexit_dummy = &__call_exitprocs;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __SINGLE_THREAD__
|
#ifndef __SINGLE_THREAD__
|
||||||
extern _LOCK_RECURSIVE_T __atexit_lock;
|
extern _LOCK_RECURSIVE_T __atexit_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,5 +19,14 @@ _DEFUN (__cxa_atexit,
|
||||||
void *arg _AND
|
void *arg _AND
|
||||||
void *d)
|
void *d)
|
||||||
{
|
{
|
||||||
return __register_exitproc (__et_cxa, (void (*)(void)) fn, arg, d);
|
#ifdef _LITE_EXIT
|
||||||
|
/* Refer to comments in __atexit.c for more details of lite exit. */
|
||||||
|
int __register_exitproc _PARAMS ((int, void (*fn) (void), _PTR, _PTR))
|
||||||
|
__attribute__ ((weak));
|
||||||
|
|
||||||
|
if (!__register_exitproc)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return __register_exitproc (__et_cxa, (void (*)(void)) fn, arg, d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,11 +54,16 @@ Supporting OS subroutines required: <<_exit>>.
|
||||||
* Exit, flushing stdio buffers if necessary.
|
* Exit, flushing stdio buffers if necessary.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
_DEFUN (exit, (code),
|
_DEFUN (exit, (code),
|
||||||
int code)
|
int code)
|
||||||
{
|
{
|
||||||
__call_exitprocs (code, NULL);
|
#ifdef _LITE_EXIT
|
||||||
|
/* Refer to comments in __atexit.c for more details of lite exit. */
|
||||||
|
void __call_exitprocs _PARAMS ((int, _PTR)) __attribute__((weak));
|
||||||
|
if (__call_exitprocs)
|
||||||
|
#endif
|
||||||
|
__call_exitprocs (code, NULL);
|
||||||
|
|
||||||
if (_GLOBAL_REENT->__cleanup)
|
if (_GLOBAL_REENT->__cleanup)
|
||||||
(*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);
|
(*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);
|
||||||
|
|
|
@ -70,6 +70,9 @@
|
||||||
/* Define if unbuffered stream file optimization is supported. */
|
/* Define if unbuffered stream file optimization is supported. */
|
||||||
#undef _UNBUF_STREAM_OPT
|
#undef _UNBUF_STREAM_OPT
|
||||||
|
|
||||||
|
/* Define if lite version of exit supported. */
|
||||||
|
#undef _LITE_EXIT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iconv encodings enabled ("to" direction)
|
* Iconv encodings enabled ("to" direction)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue