public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jim Wilson <wilson@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] RISC-V: Add _LITE_EXIT in crt0.S.
Date: Thu, 23 May 2019 00:42:00 -0000	[thread overview]
Message-ID: <20190523004205.30094.qmail@sourceware.org> (raw)

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

commit 77ac27dcf8ebd6ea314b32e563f3d128fe431581
Author: Jim Wilson <jimw@sifive.com>
Date:   Wed May 22 17:41:25 2019 -0700

    RISC-V: Add _LITE_EXIT in crt0.S.
    
    This patch adds _LITE_EXIT in crt0.S to enable "lite exit" technique in
    RISC-V. The changes have been tested in riscv/riscv-gnu-toolchain by
    riscv-dejagnu with riscv-sim.exp/riscv-sim-nano.exp.

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

diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S
index 588becf..160c078 100644
--- a/libgloss/riscv/crt0.S
+++ b/libgloss/riscv/crt0.S
@@ -9,6 +9,8 @@
    http://www.opensource.org/licenses.
 */
 
+#include "newlib.h"
+
 #=========================================================================
 # crt0.S : Entry point for RISC-V user programs
 #=========================================================================
@@ -30,9 +32,20 @@ _start:
   sub     a2, a2, a0
   li      a1, 0
   call    memset
+#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   atexit
+  la      a0, atexit
+  beqz    a0, .Lweak_atexit
+  .weak   __libc_fini_array
+#endif
 
   la      a0, __libc_fini_array   # Register global termination functions
   call    atexit                  #  to be called upon exit
+#ifdef _LITE_EXIT
+.Lweak_atexit:
+#endif
   call    __libc_init_array       # Run global initialization functions
 
   lw      a0, 0(sp)                  # a0 = argc


                 reply	other threads:[~2019-05-23  0:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190523004205.30094.qmail@sourceware.org \
    --to=wilson@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /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).