This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Introduce <elf-initfini.h> and ELF_INITFINI for all architectures
* Andreas Schwab:
> environ is empty.
That's because libc.so.6 still has DT_INIT, from which _environ and
other variables are set up. I assumed binutils would convert that into
DT_INITARRAY because the architecture is not supposed to have DT_INIT.
Without that, it's hard to declare that there is no DT_INIT, and the
patch essentially breaks ABI (because DT_INIT processing is gone).
This should fix the breakage:
Subject: 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 --git a/csu/init-first.c b/csu/init-first.c
index 1cd8a75098..1fa1633657 100644
--- a/csu/init-first.c
+++ b/csu/init-first.c
@@ -46,9 +46,8 @@ __libc_init_first (int argc, char **argv, char **envp)
/* For DSOs we do not need __libc_init_first but instead _init. */
}
-void
-attribute_hidden
-_init (int argc, char **argv, char **envp)
+static void __attribute__ ((constructor))
+init (int argc, char **argv, char **envp)
{
#endif
But I'm no longer sure if RISC-V is actually an !ELF_INITFINI
architecture.
Thanks,
Florian