PATCH: Use .init_array for libdl
H. J. Lu
hjl@lucon.org
Tue Jan 25 22:04:00 GMT 2005
Normal .init doesn't take any argument. Only .init_array in glibc
can take argc, argv, env. Without this patch, __dlfcn_argc and
__dlfcn_argv are set to random values.
H.J.
---
2005-01-25 H.J. Lu <hongjiu.lu@intel.com>
* dlfcn/dlfcn.c (init): Put it in .init_array section.
--- dlfcn/dlfcn.c.init 2005-01-11 09:23:15.000000000 -0800
+++ dlfcn/dlfcn.c 2005-01-25 13:59:18.141473205 -0800
@@ -24,10 +24,20 @@ int __dlfcn_argc attribute_hidden;
char **__dlfcn_argv attribute_hidden;
-void
-__attribute__ ((constructor))
+#ifdef HAVE_INITFINI_ARRAY
+static void
+__attribute_used__
init (int argc, char *argv[])
{
__dlfcn_argc = argc;
__dlfcn_argv = argv;
}
+
+void (*const init_array []) (int argc, char *argv[])
+ __attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
+{
+ &init
+};
+#else
+# error "Need linker with .init_array support."
+#endif
More information about the Libc-alpha
mailing list