* [PATCH v2] RISC-V: Do not use _init/_fini
@ 2018-07-31 16:41 Sebastian Huber
2018-07-31 18:34 ` Jim Wilson
2018-08-01 8:55 ` Corinna Vinschen
0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Huber @ 2018-07-31 16:41 UTC (permalink / raw)
To: newlib; +Cc: Jim Wilson
Introduce new host configuration variable "have_init_fini" which is set
to "yes" by default. Override it for RISC-V to "no".
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
libgloss/riscv/crt0.S | 11 -----------
newlib/configure.host | 8 ++++++++
newlib/libc/misc/fini.c | 4 ++++
newlib/libc/misc/init.c | 4 ++++
4 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S
index 3d2a12de5..588becfae 100644
--- a/libgloss/riscv/crt0.S
+++ b/libgloss/riscv/crt0.S
@@ -41,14 +41,3 @@ _start:
call main
tail exit
.size _start, .-_start
-
- .global _init
- .type _init, @function
- .global _fini
- .type _fini, @function
-_init:
-_fini:
- # These don't have to do anything since we use init_array/fini_array.
- ret
- .size _init, .-_init
- .size _fini, .-_fini
diff --git a/newlib/configure.host b/newlib/configure.host
index 4eebf6d95..bfa51669d 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -47,6 +47,7 @@
# crt1_dir directory where crt1 object is found
# have_crt0 "yes"/"no" if crt0 is/isn't provided.
# "" if crt0 is provided when sys_dir is set
+# have_init_fini have init/fini ("yes" or "no", set to "yes" by default)
# noinclude list of include files to not install
newlib_cflags=
@@ -65,6 +66,7 @@ mach_add_setjmp=
crt1=
crt1_dir=
have_crt0=
+have_init_fini=yes
use_libtool=no
have_sys_mach_dir=no
default_newlib_io_c99_formats=no
@@ -266,6 +268,7 @@ case "${host_cpu}" in
machine_dir=riscv
newlib_cflags="${newlib_cflags} -DHAVE_NANOSLEEP"
default_newlib_atexit_dynamic_alloc="no"
+ have_init_fini=no
;;
rl78)
machine_dir=rl78
@@ -920,6 +923,11 @@ if [ "x${xdr_dir}" = "x" ]; then
noinclude="${noinclude} rpc/types.h rpc/xdr.h"
fi
+# Have init/finit if not explicitly specified otherwise
+if [ "x${have_init_fini}" != "xno" ]; then
+ newlib_cflags="${newlib_cflags} -DHAVE_INIT_FINI"
+fi
+
if test -z "${have_crt0}" && test -n "${sys_dir}"; then
have_crt0="yes"
fi
diff --git a/newlib/libc/misc/fini.c b/newlib/libc/misc/fini.c
index ab4203bf8..56eed6cb3 100644
--- a/newlib/libc/misc/fini.c
+++ b/newlib/libc/misc/fini.c
@@ -17,7 +17,9 @@
extern void (*__fini_array_start []) (void) __attribute__((weak));
extern void (*__fini_array_end []) (void) __attribute__((weak));
+#ifdef HAVE_INIT_FINI
extern void _fini (void);
+#endif
/* Run all the cleanup routines. */
void
@@ -30,6 +32,8 @@ __libc_fini_array (void)
for (i = count; i > 0; i--)
__fini_array_start[i-1] ();
+#ifdef HAVE_INIT_FINI
_fini ();
+#endif
}
#endif
diff --git a/newlib/libc/misc/init.c b/newlib/libc/misc/init.c
index c85d6020f..95f1a7422 100644
--- a/newlib/libc/misc/init.c
+++ b/newlib/libc/misc/init.c
@@ -21,7 +21,9 @@ extern void (*__preinit_array_end []) (void) __attribute__((weak));
extern void (*__init_array_start []) (void) __attribute__((weak));
extern void (*__init_array_end []) (void) __attribute__((weak));
+#ifdef HAVE_INIT_FINI
extern void _init (void);
+#endif
/* Iterate over all the init routines. */
void
@@ -34,7 +36,9 @@ __libc_init_array (void)
for (i = 0; i < count; i++)
__preinit_array_start[i] ();
+#ifdef HAVE_INIT_FINI
_init ();
+#endif
count = __init_array_end - __init_array_start;
for (i = 0; i < count; i++)
--
2.13.7
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] RISC-V: Do not use _init/_fini
2018-07-31 16:41 [PATCH v2] RISC-V: Do not use _init/_fini Sebastian Huber
@ 2018-07-31 18:34 ` Jim Wilson
2018-08-01 8:23 ` Kito Cheng
2018-08-01 8:55 ` Corinna Vinschen
1 sibling, 1 reply; 4+ messages in thread
From: Jim Wilson @ 2018-07-31 18:34 UTC (permalink / raw)
To: Sebastian Huber; +Cc: Newlib
On Mon, Jul 30, 2018 at 1:28 AM, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
> Introduce new host configuration variable "have_init_fini" which is set
> to "yes" by default. Override it for RISC-V to "no".
I think this patch is much better than the previous one. Keeps the
config stuff in one place. It looks good to me, but I'm not a newlib
maintainer.
Jim
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] RISC-V: Do not use _init/_fini
2018-07-31 18:34 ` Jim Wilson
@ 2018-08-01 8:23 ` Kito Cheng
0 siblings, 0 replies; 4+ messages in thread
From: Kito Cheng @ 2018-08-01 8:23 UTC (permalink / raw)
To: Jim Wilson; +Cc: Sebastian Huber, Newlib
RISC-V part is LGTM.
On Wed, Aug 1, 2018 at 12:42 AM Jim Wilson <jimw@sifive.com> wrote:
> On Mon, Jul 30, 2018 at 1:28 AM, Sebastian Huber
> <sebastian.huber@embedded-brains.de> wrote:
> > Introduce new host configuration variable "have_init_fini" which is set
> > to "yes" by default. Override it for RISC-V to "no".
>
> I think this patch is much better than the previous one. Keeps the
> config stuff in one place. It looks good to me, but I'm not a newlib
> maintainer.
>
> Jim
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] RISC-V: Do not use _init/_fini
2018-07-31 16:41 [PATCH v2] RISC-V: Do not use _init/_fini Sebastian Huber
2018-07-31 18:34 ` Jim Wilson
@ 2018-08-01 8:55 ` Corinna Vinschen
1 sibling, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2018-08-01 8:55 UTC (permalink / raw)
To: Sebastian Huber; +Cc: newlib, Jim Wilson
[-- Attachment #1: Type: text/plain, Size: 564 bytes --]
On Jul 30 10:28, Sebastian Huber wrote:
> Introduce new host configuration variable "have_init_fini" which is set
> to "yes" by default. Override it for RISC-V to "no".
>
> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
> ---
> libgloss/riscv/crt0.S | 11 -----------
> newlib/configure.host | 8 ++++++++
> newlib/libc/misc/fini.c | 4 ++++
> newlib/libc/misc/init.c | 4 ++++
> 4 files changed, 16 insertions(+), 11 deletions(-)
Please push.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-01 8:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 16:41 [PATCH v2] RISC-V: Do not use _init/_fini Sebastian Huber
2018-07-31 18:34 ` Jim Wilson
2018-08-01 8:23 ` Kito Cheng
2018-08-01 8:55 ` Corinna Vinschen
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).