This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH v1 2/3] Reflect commit 2404223 (https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=2404223df651ceef42c6e2f2c9fa42fb7963db10)
- From: Alexander Fedotov <alfedotov at gmail dot com>
- To: Richard dot Earnshaw at arm dot com, newlib at sourceware dot org
- Cc: Alexander Fedotov <alfedotov at gmail dot com>
- Date: Wed, 31 Jul 2019 11:38:04 -0500
- Subject: [PATCH v1 2/3] Reflect commit 2404223 (https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=2404223df651ceef42c6e2f2c9fa42fb7963db10)
- References: <20190731163805.28834-1-alfedotov@gmail.com>
---
newlib/libc/sys/arm/crt0.S | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
index a55aa365b..5e677a23c 100644
--- a/newlib/libc/sys/arm/crt0.S
+++ b/newlib/libc/sys/arm/crt0.S
@@ -518,8 +518,17 @@ __change_mode:
for _fini to be called at program exit. */
movs r4, r0
movs r5, r1
+#ifdef _LITE_EXIT
+ /* Make reference to atexit weak to avoid unconditionally pulling in
+ support code. Refer to comments in __atexit.c for more details. */
+ .weak FUNCTION(atexit)
+ ldr r0, .Latexit
+ cmp r0, #0
+ beq .Lweak_atexit
+#endif
ldr r0, .Lfini
bl FUNCTION (atexit)
+.Lweak_atexit:
bl FUNCTION (_init)
movs r0, r4
movs r1, r5
@@ -589,6 +598,13 @@ change_back:
.LC2:
.word __bss_end__
#ifdef __USES_INITFINI__
+#ifdef _LITE_EXIT
+.Latexit:
+ .word FUNCTION(atexit)
+
+ /* Weak reference _fini in case of lite exit. */
+ .weak FUNCTION(_fini)
+#endif
.Lfini:
.word FUNCTION(_fini)
#endif
--
2.17.1