This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Use .init_array for libdl


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]