}
}
-/* ARGSUSED */
-int
-main (argc, argv, envp)
- int argc;
- char **argv;
- char **envp;
-{
- char stack_bottom_variable;
- int skip_args = 0;
- extern int errno;
- extern int sys_nerr;
-#ifdef HAVE_SETRLIMIT
- struct rlimit rlim;
-#endif
- int no_loadup = 0;
+#ifdef DOUG_LEA_MALLOC
-#ifdef LINUX_SBRK_BUG
- __sbrk (1);
-#endif
+/* malloc can be invoked even before main (e.g. by the dynamic
+ linker), so the dumped malloc state must be restored as early as
+ possible using this special hook. */
+
+static void
+malloc_initialize_hook ()
+{
+ extern char **environ;
-#ifdef DOUG_LEA_MALLOC
if (initialized)
{
if (!malloc_using_checking)
{
char **p;
- for (p = envp; *p; p++)
+ for (p = environ; *p; p++)
if (strncmp (*p, "MALLOC_CHECK_=", 14) == 0)
{
do
break;
}
}
+
malloc_set_state (malloc_state_ptr);
free (malloc_state_ptr);
}
else
malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
+}
+
+void (*__malloc_initialize_hook) () = malloc_initialize_hook;
+
+#endif /* DOUG_LEA_MALLOC */
+
+/* ARGSUSED */
+int
+main (argc, argv, envp)
+ int argc;
+ char **argv;
+ char **envp;
+{
+ char stack_bottom_variable;
+ int skip_args = 0;
+ extern int errno;
+ extern int sys_nerr;
+#ifdef HAVE_SETRLIMIT
+ struct rlimit rlim;
+#endif
+ int no_loadup = 0;
+
+#ifdef LINUX_SBRK_BUG
+ __sbrk (1);
#endif
#ifdef RUN_TIME_REMAP