From: kolerov93@gmail.com
To: newlib@sourceware.org
Cc: shahab@synopsys.com, claziss@gmail.com
Subject: [PATCH 07/15] arc: libgloss: Use atexit to setup fini routines
Date: Tue, 21 May 2024 10:56:50 +0100 [thread overview]
Message-ID: <20240521095658.10311-8-kolerov93@gmail.com> (raw)
In-Reply-To: <20240521095658.10311-1-kolerov93@gmail.com>
From: Claudiu Zissulescu <claziss@gmail.com>
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>
---
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
--
2.39.2
next prev parent reply other threads:[~2024-05-21 9:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-21 9:56 [PATCH 00/15] A series of fixes for ARC and libgloss update kolerov93
2024-05-21 9:56 ` [PATCH 01/15] arc: libgloss: Use long calls attribute for exit_halt kolerov93
2024-05-21 9:56 ` [PATCH 02/15] arc: libc: Add support of 16-entry register file kolerov93
2024-05-21 9:56 ` [PATCH 03/15] arc: libc,libgloss: Remove .file directive from .S files kolerov93
2024-05-21 9:56 ` [PATCH 04/15] arc: libc: Record r58/r59 in long-jump's buffer kolerov93
2024-05-21 9:56 ` [PATCH 05/15] arc: libgloss: Use fstat call instead of stat for nSIM kolerov93
2024-05-21 9:56 ` [PATCH 06/15] arc: libgloss: Introduce hostlink interface kolerov93
2024-05-21 9:56 ` kolerov93 [this message]
2024-05-21 9:56 ` [PATCH 08/15] arc: libgloss: Clean registers before any use kolerov93
2024-05-21 9:56 ` [PATCH 09/15] arc: libgloss: Add UART 8250 library kolerov93
2024-05-21 9:56 ` [PATCH 10/15] arc: libgloss: Add a linker script common for all boards kolerov93
2024-05-21 9:56 ` [PATCH 11/15] arc: libgloss: Add support of IoT Development Kit board kolerov93
2024-05-21 9:56 ` [PATCH 12/15] arc: libgloss: Add support of HS " kolerov93
2024-05-21 9:56 ` [PATCH 13/15] arc: libgloss: Add support of EM SDP board kolerov93
2024-05-21 9:56 ` [PATCH 14/15] arc: libgloss: Add support of EM Starter Kit board kolerov93
2024-05-21 9:56 ` [PATCH 15/15] arc: libgloss: Add build rules for new boards kolerov93
2024-05-22 18:28 ` [PATCH 00/15] A series of fixes for ARC and libgloss update Jeff Johnston
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240521095658.10311-8-kolerov93@gmail.com \
--to=kolerov93@gmail.com \
--cc=claziss@gmail.com \
--cc=newlib@sourceware.org \
--cc=shahab@synopsys.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).