[Top][All Lists]

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

[avr-libc-dev] [patch #8556] Fix atexit.c

From: Georg-Johann Lay
Subject: [avr-libc-dev] [patch #8556] Fix atexit.c
Date: Tue, 14 Oct 2014 11:40:08 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de; rv: Gecko/20120306 Firefox/3.6.28


                 Summary: Fix atexit.c
                 Project: AVR C Runtime Library
            Submitted by: gjlayde
            Submitted on: Di 14 Okt 2014 11:40:07 GMT
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any



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


        * 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.


File Attachments:

Date: Di 14 Okt 2014 11:40:07 GMT  Name: atexit.diff  Size: 1kB   By: gjlayde
patch to fix atexit.c issues


Reply to this item at:


  Nachricht gesendet von/durch Savannah

reply via email to

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