summaryrefslogtreecommitdiff
path: root/csu
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-02-18 14:42:41 +0100
committerFlorian Weimer <fweimer@redhat.com>2020-02-18 15:12:25 +0100
commitf4349837d93b4dfe9ba09791e280ee2d6c99919f (patch)
tree2d9b57dc8a2b38bc369e0e0f89232046d8be38ca /csu
parent6e05978f0c30e52420e086cc3156655471e6fb0a (diff)
downloadglibc-f4349837d93b4dfe9ba09791e280ee2d6c99919f.tar.gz
Introduce <elf-initfini.h> 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 <dl-machine.h> is incompatible with assembler code. <sysdep.h> 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. <elf-initfini.h> is replicated for legacy architectures which need DT_INIT/DT_FINI support. New architectures follow the generic default and disable it.
Diffstat (limited to 'csu')
-rw-r--r--csu/elf-init.c7
-rw-r--r--csu/gmon-start.c8
2 files changed, 12 insertions, 3 deletions
diff --git a/csu/elf-init.c b/csu/elf-init.c
index b713c8b0fb..98b3f11ff5 100644
--- a/csu/elf-init.c
+++ b/csu/elf-init.c
@@ -34,6 +34,7 @@
<https://www.gnu.org/licenses/>. */
#include <stddef.h>
+#include <elf-initfini.h>
/* 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 2803be342a..da9f04c522 100644
--- a/csu/gmon-start.c
+++ b/csu/gmon-start.c
@@ -37,6 +37,7 @@
#include <sys/gmon.h>
#include <stdlib.h>
#include <unistd.h>
+#include <elf-initfini.h>
#define __ASSEMBLY__
#include <entry.h>
@@ -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)