aboutsummaryrefslogtreecommitdiff
path: root/libgloss
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2019-05-22 17:41:25 -0700
committerJim Wilson <jimw@sifive.com>2019-05-22 17:41:25 -0700
commit77ac27dcf8ebd6ea314b32e563f3d128fe431581 (patch)
tree937fe2b8810531e7a924ff9e71acb9a4c16da647 /libgloss
parent5c86f0da5f07791c01477380a0635c6d38a9b33b (diff)
downloadnewlib-77ac27dcf8ebd6ea314b32e563f3d128fe431581.zip
newlib-77ac27dcf8ebd6ea314b32e563f3d128fe431581.tar.gz
newlib-77ac27dcf8ebd6ea314b32e563f3d128fe431581.tar.bz2
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.
Diffstat (limited to 'libgloss')
-rw-r--r--libgloss/riscv/crt0.S13
1 files changed, 13 insertions, 0 deletions
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