This is the mail archive of the
mailing list for the newlib project.
Re: [PATCH] New configuration option for lite exit
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: newlib at sourceware dot org
- Date: Thu, 13 Jun 2013 16:55:12 -0400
- 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> <CAL0py25PtLmDUyKXAQqdk8GFkP45AWUBmrffL+8M3iKJaxZKAQ at mail dot gmail dot com>
On 06/07/2013 05:46 AM, Ye Joey wrote:
On Thu, May 30, 2013 at 3:29 AM, Jeff Johnston <email@example.com> 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.
Please add such documentation to your patch. I might suggest both
adding it to the new README section you have started regarding newlib
configuration options and to at least one of the source files and you
can reference that file from the others (e.g. put it in atexit and have
the other files that are changed tell the developer to look in atexit.c
for more details)..
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.
Maybe I'm missing something. Following the logic, __call_exitprocs is a
weak reference in exit. If the user calls on_exit without an atexit()
call then nothing solidifies the __call_exitprocs linkage.
If I am correct, please fix and update documentation.