RISC-V: Do not use _init/_fini
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>
This commit is contained in:
parent
62a5c6b02c
commit
6158b30e3e
@ -41,14 +41,3 @@ _start:
|
|||||||
call main
|
call main
|
||||||
tail exit
|
tail exit
|
||||||
.size _start, .-_start
|
.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
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
# crt1_dir directory where crt1 object is found
|
# crt1_dir directory where crt1 object is found
|
||||||
# have_crt0 "yes"/"no" if crt0 is/isn't provided.
|
# have_crt0 "yes"/"no" if crt0 is/isn't provided.
|
||||||
# "" if crt0 is provided when sys_dir is set
|
# "" 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
|
# noinclude list of include files to not install
|
||||||
|
|
||||||
newlib_cflags=
|
newlib_cflags=
|
||||||
@ -65,6 +66,7 @@ mach_add_setjmp=
|
|||||||
crt1=
|
crt1=
|
||||||
crt1_dir=
|
crt1_dir=
|
||||||
have_crt0=
|
have_crt0=
|
||||||
|
have_init_fini=yes
|
||||||
use_libtool=no
|
use_libtool=no
|
||||||
have_sys_mach_dir=no
|
have_sys_mach_dir=no
|
||||||
default_newlib_io_c99_formats=no
|
default_newlib_io_c99_formats=no
|
||||||
@ -266,6 +268,7 @@ case "${host_cpu}" in
|
|||||||
machine_dir=riscv
|
machine_dir=riscv
|
||||||
newlib_cflags="${newlib_cflags} -DHAVE_NANOSLEEP"
|
newlib_cflags="${newlib_cflags} -DHAVE_NANOSLEEP"
|
||||||
default_newlib_atexit_dynamic_alloc="no"
|
default_newlib_atexit_dynamic_alloc="no"
|
||||||
|
have_init_fini=no
|
||||||
;;
|
;;
|
||||||
rl78)
|
rl78)
|
||||||
machine_dir=rl78
|
machine_dir=rl78
|
||||||
@ -920,6 +923,11 @@ if [ "x${xdr_dir}" = "x" ]; then
|
|||||||
noinclude="${noinclude} rpc/types.h rpc/xdr.h"
|
noinclude="${noinclude} rpc/types.h rpc/xdr.h"
|
||||||
fi
|
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
|
if test -z "${have_crt0}" && test -n "${sys_dir}"; then
|
||||||
have_crt0="yes"
|
have_crt0="yes"
|
||||||
fi
|
fi
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
extern void (*__fini_array_start []) (void) __attribute__((weak));
|
extern void (*__fini_array_start []) (void) __attribute__((weak));
|
||||||
extern void (*__fini_array_end []) (void) __attribute__((weak));
|
extern void (*__fini_array_end []) (void) __attribute__((weak));
|
||||||
|
|
||||||
|
#ifdef HAVE_INIT_FINI
|
||||||
extern void _fini (void);
|
extern void _fini (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Run all the cleanup routines. */
|
/* Run all the cleanup routines. */
|
||||||
void
|
void
|
||||||
@ -30,6 +32,8 @@ __libc_fini_array (void)
|
|||||||
for (i = count; i > 0; i--)
|
for (i = count; i > 0; i--)
|
||||||
__fini_array_start[i-1] ();
|
__fini_array_start[i-1] ();
|
||||||
|
|
||||||
|
#ifdef HAVE_INIT_FINI
|
||||||
_fini ();
|
_fini ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,7 +21,9 @@ extern void (*__preinit_array_end []) (void) __attribute__((weak));
|
|||||||
extern void (*__init_array_start []) (void) __attribute__((weak));
|
extern void (*__init_array_start []) (void) __attribute__((weak));
|
||||||
extern void (*__init_array_end []) (void) __attribute__((weak));
|
extern void (*__init_array_end []) (void) __attribute__((weak));
|
||||||
|
|
||||||
|
#ifdef HAVE_INIT_FINI
|
||||||
extern void _init (void);
|
extern void _init (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Iterate over all the init routines. */
|
/* Iterate over all the init routines. */
|
||||||
void
|
void
|
||||||
@ -34,7 +36,9 @@ __libc_init_array (void)
|
|||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
__preinit_array_start[i] ();
|
__preinit_array_start[i] ();
|
||||||
|
|
||||||
|
#ifdef HAVE_INIT_FINI
|
||||||
_init ();
|
_init ();
|
||||||
|
#endif
|
||||||
|
|
||||||
count = __init_array_end - __init_array_start;
|
count = __init_array_end - __init_array_start;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user