This is the mail archive of the
mailing list for the newlib project.
Re: [PATCH] New configuration option for lite exit
- From: Ye Joey <joey dot ye dot cc at gmail dot com>
- To: Jeff Johnston <jjohnstn at redhat dot com>
- Cc: newlib at sourceware dot org
- Date: Fri, 7 Jun 2013 17:46:53 +0800
- Subject: Re: [PATCH] New configuration option for lite exit
- References: <000001ce3b52$4646b880$d2d42980$ at arm dot com> <517BB415 dot 2080601 at embedded-brains dot de> <CAL0py27CtHj=h3tmr8W+CdnpM-zcF0GPbQxWeNJayYyqcB2REg at mail dot gmail dot com> <20130528102816 dot GE5264 at calimero dot vinschen dot de> <51A65720 dot 8090604 at redhat dot com>
On Thu, May 30, 2013 at 3:29 AM, Jeff Johnston <firstname.lastname@example.org> wrote:
> Sorry I have been busy with an up-coming Eclipse release and two customer
> Looking at it, this needs documentation as it is not straight-forward with
> regards to how the whole design ties together (i.e. what are the behaviour
> rules for the application / compiler). You might also state what this
> accomplishes on your initial platform.
To explain what this patch is doing, following call relation is useful:
_mainCRTStartup -> atexit -> __register_exitproc
_mainCRTStartup -> exit -> __call_exitprocs
_mainCRTStartup -> __libc_init_array -> __cxa_atexit -> __register_exitproc
Here an -> means arrow tail invokes arrow head. All invocations here
are non-weak reference in current newlib.
This patch does three things:
1. Change some of above invocations to weak, so that size expansive
function __register_exitproc and __call_exitprocs can be skipped if
2. Build dependences between symbol A and B, so that if A is non-weak
referenced B will also be.
3. Add new option to enable/disable above
As for item 1, following calls are changed to weak reference:
_mainCRTStartup w-> atexit
exit w-> __call_exitprocs
__cxa_atexit w-> __register_exitproc
By doing so, a normal program without atexit will escape from the
burden of cleaning up.
As for item 2, following symbol dependences are built:
atexit and __call_exitprocs, so that if atexit is explicitly called
by user, it will be effective when exit
__cxa_finalize and __register_exitproc, this might not be necessary.
__register_exitproc and __call_exitproc is more appropriate. Should
update this later.
As for item 3, --enable-lite-exit is introduced to enable above
change, which is by default disabled.
> AFAICT, if a call is made to __cxa_atexit, nothing will occur unless a call
> is also made to __cxa_finalize or atexit() or on_exit(). The exit list
> won't be run on exit if just on_exit() is called because __call_exitprocs()
> won't be brought in.
This doesn't appear to be true, as __call_exitprocs is always called in exit.