From f4349837d93b4dfe9ba09791e280ee2d6c99919f Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 18 Feb 2020 14:42:41 +0100 Subject: Introduce and ELF_INITFINI for all architectures This supersedes the init_array sysdeps directory. It allows us to check for ELF_INITFINI in both C and assembler code, and skip DT_INIT and DT_FINI processing completely on newer architectures. A new header file is needed because is incompatible with assembler code. is compatible with assembler code, but it cannot be included in all assembler files because on some architectures, it redefines register names, and some assembler files conflict with that. is replicated for legacy architectures which need DT_INIT/DT_FINI support. New architectures follow the generic default and disable it. --- csu/elf-init.c | 7 ++++--- csu/gmon-start.c | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'csu') diff --git a/csu/elf-init.c b/csu/elf-init.c index b713c8b..98b3f11 100644 --- a/csu/elf-init.c +++ b/csu/elf-init.c @@ -34,6 +34,7 @@ . */ #include +#include /* These magic symbols are provided by the linker. */ @@ -49,7 +50,7 @@ extern void (*__fini_array_start []) (void) attribute_hidden; extern void (*__fini_array_end []) (void) attribute_hidden; -#ifndef NO_INITFINI +#if ELF_INITFINI /* These function symbols are provided for the .init/.fini section entry points automagically by the linker. */ extern void _init (void); @@ -79,7 +80,7 @@ __libc_csu_init (int argc, char **argv, char **envp) } #endif -#ifndef NO_INITFINI +#if ELF_INITFINI _init (); #endif @@ -99,7 +100,7 @@ __libc_csu_fini (void) while (i-- > 0) (*__fini_array_start [i]) (); -# ifndef NO_INITFINI +# if ELF_INITFINI _fini (); # endif #endif diff --git a/csu/gmon-start.c b/csu/gmon-start.c index 2803be3..da9f04c 100644 --- a/csu/gmon-start.c +++ b/csu/gmon-start.c @@ -37,6 +37,7 @@ #include #include #include +#include #define __ASSEMBLY__ #include @@ -59,6 +60,13 @@ extern char etext[]; # endif #endif +#if !ELF_INITFINI +/* Instead of defining __gmon_start__ globally in gcrt1.o, we make it + static and just put a pointer to it into the .preinit_array + section. */ +# define GMON_START_ARRAY_SECTION ".preinit_array" +#endif + #ifdef GMON_START_ARRAY_SECTION static void __gmon_start__ (void); static void (*const gmon_start_initializer) (void) -- cgit v1.1