public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] csu: Use ELF constructor instead of _init in libc.so
@ 2020-02-25 14:01 Florian Weimer
0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2020-02-25 14:01 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=783e641fbae0cd1ab32d278216247a6f793dd722
commit 783e641fbae0cd1ab32d278216247a6f793dd722
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon Feb 24 11:50:24 2020 +0100
csu: Use ELF constructor instead of _init in libc.so
On !ELF_INITFINI architectures, _init is no longer called by the
dynamic linker. We can use an ELF constructor instead because the
constructor order does not matter. (The other constructors are used
to set up libio vtable bypasses and do not depend on this
initialization routine.)
Diff:
---
csu/init-first.c | 12 ++++++------
elf/soinit.c | 2 +-
include/libc-internal.h | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/csu/init-first.c b/csu/init-first.c
index 1cd8a75..264e6f3 100644
--- a/csu/init-first.c
+++ b/csu/init-first.c
@@ -43,12 +43,11 @@ void
__libc_init_first (int argc, char **argv, char **envp)
{
#ifdef SHARED
- /* For DSOs we do not need __libc_init_first but instead _init. */
+ /* For DSOs we do not need __libc_init_first but an ELF constructor. */
}
-void
-attribute_hidden
-_init (int argc, char **argv, char **envp)
+static void __attribute__ ((constructor))
+_init_first (int argc, char **argv, char **envp)
{
#endif
@@ -86,8 +85,9 @@ _init (int argc, char **argv, char **envp)
/* This function is defined here so that if this file ever gets into
ld.so we will get a link error. Having this file silently included
- in ld.so causes disaster, because the _init definition above will
- cause ld.so to gain an init function, which is not a cool thing. */
+ in ld.so causes disaster, because the _init_first definition above
+ will cause ld.so to gain an ELF constructor, which is not a cool
+ thing. */
extern void _dl_start (void) __attribute__ ((noreturn));
diff --git a/elf/soinit.c b/elf/soinit.c
index fe99357..538eb68 100644
--- a/elf/soinit.c
+++ b/elf/soinit.c
@@ -20,7 +20,7 @@ run_hooks (void (*const list[]) (void))
(**list) ();
}
-/* This function will be called from _init in init-first.c. */
+/* This function will be called from _init_first in init-first.c. */
void
__libc_global_ctors (void)
{
diff --git a/include/libc-internal.h b/include/libc-internal.h
index fcd2146..4c74f6b 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.h
@@ -24,7 +24,7 @@
/* Initialize the `__libc_enable_secure' flag. */
extern void __libc_init_secure (void);
-/* This function will be called from _init in init-first.c. */
+/* This function will be called from _init_first in init-first.c. */
extern void __libc_global_ctors (void);
/* Discover the tick frequency of the machine if something goes wrong,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-25 14:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 14:01 [glibc] csu: Use ELF constructor instead of _init in libc.so Florian Weimer
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).