[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] [patch, avr-libc] Fix atexit.c
From: |
Georg-Johann Lay |
Subject: |
[avr-gcc-list] [patch, avr-libc] Fix atexit.c |
Date: |
Tue, 14 Oct 2014 12:43:02 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
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:
$ 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.
ii)
__atexit_fini is not naked thus will crash the program as it is returning.
iii)
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.
iv)
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.
Johann
* 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.
atexit.diff
Description: Text Data
- [avr-gcc-list] [patch, avr-libc] Fix atexit.c,
Georg-Johann Lay <=