public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] arc: libgloss: Use atexit to setup fini routines
@ 2024-05-22 18:28 Jeff Johnston
  0 siblings, 0 replies; only message in thread
From: Jeff Johnston @ 2024-05-22 18:28 UTC (permalink / raw)
  To: newlib-cvs

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

commit 6cfdd3350ee6f8c8ba8ccd46505d70a624ef3f75
Author: Claudiu Zissulescu <claziss@gmail.com>
Date:   Tue May 21 10:56:50 2024 +0100

    arc: libgloss: Use atexit to setup fini routines
    
    Use atexit funtion to setup fini routines to be called on exit
    instead of filling in __atexit structures manually.
    
    Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>

Diff:
---
 libgloss/arc/crt0.S | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/libgloss/arc/crt0.S b/libgloss/arc/crt0.S
index 235f81028..1999e602b 100644
--- a/libgloss/arc/crt0.S
+++ b/libgloss/arc/crt0.S
@@ -178,27 +178,12 @@ __start:
 
 #endif /* !__ARC601__ */
 
-; Some  targets use the .init and .fini sections to create constructors and
-; destructors, and for these targets we need to call the _init function and
-; arrange for _fini to be called at program exit.
-	mov_s	r13, r0
-	mov_s	r14, r1
-	; calling atexit drags in malloc, so instead poke the function
-	; address directly into the reent structure
-	ld	r1, [gp, @_impure_ptr@sda]
-	mov_s	r1, @__atexit0
-	mov_s	r2, @__atexit
-	st_s	r1, [r2, 0]		; __atexit = &__atexit0
-	mov_s	r0, 1
-	st_s	r0, [r1, 4]		; __atexit0._ind = 1
-	mov_s	r0, @_fini
-	st_s	r0, [r1, 8]		; __atexit0._fns[0] = _fini
-; branch to _init
-#if defined (__ARCEM__) || defined (__ARCHS__)
+	;; Call constructors
 	jl	@_init
-#else
-	bl	@_init
-#endif /* __ARCEM__ || __ARCHS__ */
+
+;;; Setup fini routines to be called from exit
+	mov_s	r0, @_fini
+	jl	@atexit
 
 #ifdef PROFILE_SUPPORT /* Defined in gcrt0.S.  */
 	mov	r0,@__start

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-22 18:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22 18:28 [newlib-cygwin/main] arc: libgloss: Use atexit to setup fini routines Jeff Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).