[PATCH 2/2] RISC-V: Add _LITE_EXIT in crt0.S.
ilia.diachkov@optimitech.com
ilia.diachkov@optimitech.com
Fri May 17 23:53:00 GMT 2019
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.
From d51d7c69a2c60041ef583686f24ccae74b675edc Mon Sep 17 00:00:00 2001
From: Ilia Diachkov <ilia.diachkov@optimitech.com>
Date: Sat, 18 May 2019 02:08:36 +0300
Subject: [PATCH 2/2] RISC-V: Add _LITE_EXIT in crt0.S.
---
libgloss/riscv/crt0.S | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S
index 3d2a12d..7e1c025 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,18 @@ _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
+.Lweak_atexit:
call __libc_init_array # Run global initialization functions
lw a0, 0(sp) # a0 = argc
--
1.8.3.1
More information about the Newlib
mailing list