patchAVR C Runtime Library - Patches: patch #8556, Fix atexit.c

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #8556: Fix atexit.c

Submitter:  Georg-Johann Lay <gjlayde>
Submitted:  Tue 14 Oct 2014 11:40:07 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed

Wed 07 Oct 2015 07:03:41 AM UTC, comment #3: 
Senthil Kumar Selvaraj <saaadhu>
Group Member
Wed 15 Oct 2014 07:35:53 PM UTC, comment #2: 


> is it possible to remove outdated patches?


At least for us maintainers, it is.  I dropped the outdated
patch.

Joerg Wunsch <joerg_wunsch>
Group administrator
Wed 15 Oct 2014 09:30:20 AM UTC, comment #1: 

Attached an updated patch (is it possible to remove outdated patches?)

- Move calling atexit functions from .fini7 up to .fini8.
- Handle cases where a destructor calls exit.



        * libc/stdlib/atexit.c (__atexit_fini): Rename to...
        (atexit_fini): ...this.  Make static, naked, and used.
        Move to section .fini8.  Outsource worker code to...
        (atexit_finido): ...this new function.
        (atexit_p): Renamed from __atexit_p.  Make static.


(file #32277)

Georg-Johann Lay <gjlayde>
Tue 14 Oct 2014 11:40:07 AM UTC, original submission:  

This patch fixes several atexit issues:

  • 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:



$ avr-gcc main.c -mmcu=atmega128

$INSTALL/lib/gcc/avr/$VERSION/../../../../avr/bin/ld: section .fini6a loaded at [00000390,000003b7] overlaps section .data loaded at [00000390,00000395]

collect2: error: ld returned 1 exit status


The patch moves that code to .fini7 so that atexit functions are sequenced before static destructors which is closest to C++ spec.

  • __atexit_fini is not naked thus will crash the program as it is returning.


  • In order to arrange the hypothetical case that the code generated by atexit_fini would need a frame it's now in a proper (non-naked) function called by now naked atexit_fini.


  • Except atexit, nothing in atexit.c needs to be global --> make static.


Even though atexit is exotic in non-hosted contexts it's nice to see it working, e.g. to reduce testsuite fallout.



Cf. also

http://lists.nongnu.org/archive/html/avr-gcc-list/2014-10/msg00020.html



        * libc/stdlib/atexit.c (__atexit_fini): Rename to...
        (atexit_fini): ...this.  Make static, naked, and used.
        Move to section .fini7.  Outsource worker code to...
        (atexit_finido): ...this new function.
        (atexit_p): Renamed from __atexit_p.  Make static.


Georg-Johann Lay <gjlayde>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #32277:  atexit-v2.diff added by gjlayde (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by saaadhu (Posted a comment)
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by gjlayde (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-10-07 saaadhu StatusNone Done
        Open/ClosedOpen Closed
    2014-10-15 joerg_wunsch Attached File#32269 Removed
    2014-10-15 gjlayde Attached File- Added atexit-v2.diff, #32277
    2014-10-14 gjlayde Attached File- Added atexit.diff, #32269

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code