avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] [patch, avr-libc] Fix atexit.c


From: Joern Rennecke
Subject: Re: [avr-gcc-list] [patch, avr-libc] Fix atexit.c
Date: Tue, 14 Oct 2014 15:07:47 +0100

On 14 October 2014 11:43, Georg-Johann Lay <address@hidden> wrote:
> atexit.c has several issues which are fixed by the patch below:
>
>
> i)
> Issuance of calls to functions as registered by atexit() is located in
> section .fini6a.  As the current linker description does not handle that
> section it's treated as orphan and located conflicting with other sections:

I actually wrote a binutils patch at the same time as the atexit implementation:

address@hidden:embecosm/avr-binutils-gdb.git branch avr-mainline commit
640411f2fb984e70c4ab06154089692db1734a97

I just haven't gotten around to push this to the main repo yet.

> ii)
> __atexit_fini is not naked thus will crash the program as it is returning.

Good point.  However, I'd prefer to add a new attribute to just say
that the function returns by falling through at the end.
Opinions on how to name this?  "fallthrough" ?  "return_falls_through" ?
"ctor_dtor" (although that can get confusing with the constructor /
destructor attribute) ?
Overload the meaning of the section attribute so that .init / .fini
section 'magically'
causes the different return?

+atexit_finido (void)
 {
-  while (__atexit_p)
+  while (atexit_p)
     {
-      void (*fun) (void) = __atexit_p->fun;
-      __atexit_p = __atexit_p->next;
-      (*fun) ();
+      atexit_p->fun();
+      atexit_p = atexit_p->next;

This introduces a bug.  If the called function calls exit (e.g.
because it throws
an error), you get an infinite recursion.  The pointer must be updated before
the function is called.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]