[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/emacs.c
From: |
Jan Djärv |
Subject: |
[Emacs-diffs] Changes to emacs/src/emacs.c |
Date: |
Wed, 20 Oct 2004 12:47:55 -0400 |
Index: emacs/src/emacs.c
diff -c emacs/src/emacs.c:1.342 emacs/src/emacs.c:1.343
*** emacs/src/emacs.c:1.342 Thu Jun 24 20:24:52 2004
--- emacs/src/emacs.c Wed Oct 20 16:23:30 2004
***************
*** 67,72 ****
--- 67,76 ----
#include <sys/resource.h>
#endif
+ #ifdef HAVE_PERSONALITY_LINUX32
+ #include <sys/personality.h>
+ #endif
+
#ifndef O_RDWR
#define O_RDWR 2
#endif
***************
*** 192,197 ****
--- 196,212 ----
Tells GC how to save a copy of the stack. */
char *stack_bottom;
+ /* The address where the heap starts (from the first sbrk (0) call). */
+ static void *my_heap_start;
+
+ /* The gap between BSS end and heap start as far as we can tell. */
+ static unsigned long heap_bss_diff;
+
+ /* If the gap between BSS end and heap start is larger than this we try to
+ work around it, and if that fails, output a warning in dump-emacs. */
+ #define MAX_HEAP_BSS_DIFF (1024*1024)
+
+
#ifdef HAVE_WINDOW_SYSTEM
extern Lisp_Object Vwindow_system;
#endif /* HAVE_WINDOW_SYSTEM */
***************
*** 733,739 ****
free (malloc_state_ptr);
}
else
! malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
}
void (*__malloc_initialize_hook) () = malloc_initialize_hook;
--- 748,758 ----
free (malloc_state_ptr);
}
else
! {
! if (my_heap_start == 0)
! my_heap_start = sbrk (0);
! malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
! }
}
void (*__malloc_initialize_hook) () = malloc_initialize_hook;
***************
*** 809,814 ****
--- 828,844 ----
stack_base = &dummy;
#endif
+ if (!initialized)
+ {
+ extern char my_endbss[];
+ extern char *my_endbss_static;
+
+ if (my_heap_start == 0)
+ my_heap_start = sbrk (0);
+
+ heap_bss_diff = (char *)my_heap_start - max (my_endbss,
my_endbss_static);
+ }
+
#ifdef LINUX_SBRK_BUG
__sbrk (1);
#endif
***************
*** 852,857 ****
--- 882,909 ----
}
}
+ #ifdef HAVE_PERSONALITY_LINUX32
+ /* See if there is a gap between the end of BSS and the heap.
+ In that case, set personality and exec ourself again. */
+ if (!initialized
+ && (strcmp (argv[argc-1], "dump") == 0
+ || strcmp (argv[argc-1], "bootstrap") == 0)
+ && heap_bss_diff > MAX_HEAP_BSS_DIFF)
+ {
+ if (! getenv ("EMACS_HEAP_EXEC"))
+ {
+ /* Set this so we only do this once. */
+ putenv("EMACS_HEAP_EXEC=true");
+ personality (PER_LINUX32);
+ execvp (argv[0], argv);
+
+ /* If the exec fails, try to dump anyway. */
+ perror ("execvp");
+ }
+ }
+ #endif /* HAVE_PERSONALITY_LINUX32 */
+
+
/* Map in shared memory, if we are using that. */
#ifdef HAVE_SHM
if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
***************
*** 2130,2135 ****
--- 2182,2198 ----
if (! noninteractive)
error ("Dumping Emacs works only in batch mode");
+ if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
+ {
+ fprintf (stderr,
"**************************************************\n");
+ fprintf (stderr, "Warning: Your system has a gap between BSS and
the\n");
+ fprintf (stderr, "heap. This usually means that exec-shield or\n");
+ fprintf (stderr, "something similar is in effect. The dump may
fail\n");
+ fprintf (stderr, "because of this. See the section about
exec-shield\n");
+ fprintf (stderr, "in etc/PROBLEMS for more information.\n");
+ fprintf (stderr,
"**************************************************\n");
+ }
+
/* Bind `command-line-processed' to nil before dumping,
so that the dumped Emacs will process its command line
and set up to work with X windows if appropriate. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/src/emacs.c,
Jan Djärv <=