[newlib-cygwin/main] libgloss: csky: use atexit to call fini-array functions.

Corinna Vinschen corinna@sourceware.org
Fri Jan 13 13:08:48 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7f4c04755ef84feba6c24b34b539330e5ee2bd4d

commit 7f4c04755ef84feba6c24b34b539330e5ee2bd4d
Author:     Xianmiao Qu <cooper.qu@linux.alibaba.com>
AuthorDate: Fri Jan 13 20:46:47 2023 +0800
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Jan 13 14:08:23 2023 +0100

    libgloss: csky: use atexit to call fini-array functions.
    
    __libc_fini_array should be called upon exit to call the
    global termination functions in fini-array, use atexit to
    register it at __start.

Diff:
---
 libgloss/csky/crt0.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libgloss/csky/crt0.S b/libgloss/csky/crt0.S
index a0651a734673..49f7da36478f 100644
--- a/libgloss/csky/crt0.S
+++ b/libgloss/csky/crt0.S
@@ -150,6 +150,8 @@ __start:
 	 * Assember start up done, C codes start here.
 	 */
 __goto_c:
+	lrw     r0, __libc_fini_array   # Register global termination functions
+	jbsr    atexit                  #  to be called upon exit
 	/*jsri	main*/
 	lrw	r5, __libc_init_array
 	jsr	r5


More information about the Newlib-cvs mailing list