Commit dede2792 authored by Jan Djärv's avatar Jan Djärv

* emacs.c (my_heap_start, heap_bss_diff, MAX_HEAP_BSS_DIFF):

New variables and constant.
(main): Calculate heap_bss_diff.  If we are dumping and the
heap_bss_diff is greater than MAX_HEAP_BSS_DIFF, set PER_LINUX32
and exec ourself again.
(Fdump_emacs): If heap_bss_diff is greater than MAX_HEAP_BSS_DIFF
print a warning.

* lastfile.c: Make my_endbss and my_endbss_static available on all
platforms.

* Makefile.in (RUN_TEMACS): Remove @SETARCH@.
* config.in (HAVE_PERSONALITY_LINUX32): Regenerate.
parent f17e308a
2004-10-20 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
* emacs.c (my_heap_start, heap_bss_diff, MAX_HEAP_BSS_DIFF):
New variables and constant.
(main): Calculate heap_bss_diff. If we are dumping and the
heap_bss_diff is greater than MAX_HEAP_BSS_DIFF, set PER_LINUX32
and exec ourself again.
(Fdump_emacs): If heap_bss_diff is greater than MAX_HEAP_BSS_DIFF
print a warning.
* lastfile.c: Make my_endbss and my_endbss_static available on all
platforms.
* Makefile.in (RUN_TEMACS): Remove @SETARCH@.
* config.in (HAVE_PERSONALITY_LINUX32): Regenerate.
2004-10-19 Luc Teirlinck <teirllm@auburn.edu> 2004-10-19 Luc Teirlinck <teirllm@auburn.edu>
* data.c (Flocal_variable_if_set_p): Doc fix. * data.c (Flocal_variable_if_set_p): Doc fix.
......
...@@ -905,12 +905,7 @@ LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) \ ...@@ -905,12 +905,7 @@ LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) \
#define OBJECTS_MACHINE #define OBJECTS_MACHINE
#endif #endif
#ifdef HAVE_RANDOM_HEAPSTART
#undef i386
RUN_TEMACS = @SETARCH@ i386 ./temacs
#else
RUN_TEMACS = ./temacs RUN_TEMACS = ./temacs
#endif
all: emacs${EXEEXT} OTHER_FILES all: emacs${EXEEXT} OTHER_FILES
......
...@@ -414,6 +414,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -414,6 +414,9 @@ Boston, MA 02111-1307, USA. */
/* Define to 1 if you have the <nlist.h> header file. */ /* Define to 1 if you have the <nlist.h> header file. */
#undef HAVE_NLIST_H #undef HAVE_NLIST_H
/* Define to 1 if personality LINUX32 can be set. */
#undef HAVE_PERSONALITY_LINUX32
/* Define to 1 if you have the png library (-lpng). */ /* Define to 1 if you have the png library (-lpng). */
#undef HAVE_PNG #undef HAVE_PNG
...@@ -432,9 +435,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -432,9 +435,6 @@ Boston, MA 02111-1307, USA. */
/* Define to 1 if you have the `random' function. */ /* Define to 1 if you have the `random' function. */
#undef HAVE_RANDOM #undef HAVE_RANDOM
/* Define to 1 if this OS randomizes the start address of the heap. */
#undef HAVE_RANDOM_HEAPSTART
/* Define to 1 if you have the `recvfrom' function. */ /* Define to 1 if you have the `recvfrom' function. */
#undef HAVE_RECVFROM #undef HAVE_RECVFROM
...@@ -757,9 +757,9 @@ Boston, MA 02111-1307, USA. */ ...@@ -757,9 +757,9 @@ Boston, MA 02111-1307, USA. */
/* If using the C implementation of alloca, define if you know the /* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be direction of stack growth for your system; otherwise it will be
automatically deduced at run-time. automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */ STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION #undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
......
...@@ -67,6 +67,10 @@ Boston, MA 02111-1307, USA. */ ...@@ -67,6 +67,10 @@ Boston, MA 02111-1307, USA. */
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#ifdef HAVE_PERSONALITY_LINUX32
#include <sys/personality.h>
#endif
#ifndef O_RDWR #ifndef O_RDWR
#define O_RDWR 2 #define O_RDWR 2
#endif #endif
...@@ -192,6 +196,17 @@ int display_arg; ...@@ -192,6 +196,17 @@ int display_arg;
Tells GC how to save a copy of the stack. */ Tells GC how to save a copy of the stack. */
char *stack_bottom; 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 #ifdef HAVE_WINDOW_SYSTEM
extern Lisp_Object Vwindow_system; extern Lisp_Object Vwindow_system;
#endif /* HAVE_WINDOW_SYSTEM */ #endif /* HAVE_WINDOW_SYSTEM */
...@@ -733,7 +748,11 @@ malloc_initialize_hook () ...@@ -733,7 +748,11 @@ malloc_initialize_hook ()
free (malloc_state_ptr); free (malloc_state_ptr);
} }
else else
malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; {
if (my_heap_start == 0)
my_heap_start = sbrk (0);
malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
}
} }
void (*__malloc_initialize_hook) () = malloc_initialize_hook; void (*__malloc_initialize_hook) () = malloc_initialize_hook;
...@@ -809,6 +828,17 @@ main (argc, argv ...@@ -809,6 +828,17 @@ main (argc, argv
stack_base = &dummy; stack_base = &dummy;
#endif #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 #ifdef LINUX_SBRK_BUG
__sbrk (1); __sbrk (1);
#endif #endif
...@@ -852,6 +882,28 @@ main (argc, argv ...@@ -852,6 +882,28 @@ main (argc, argv
} }
} }
#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. */ /* Map in shared memory, if we are using that. */
#ifdef HAVE_SHM #ifdef HAVE_SHM
if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
...@@ -2130,6 +2182,17 @@ You must run Emacs in batch mode in order to dump it. */) ...@@ -2130,6 +2182,17 @@ You must run Emacs in batch mode in order to dump it. */)
if (! noninteractive) if (! noninteractive)
error ("Dumping Emacs works only in batch mode"); 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, /* Bind `command-line-processed' to nil before dumping,
so that the dumped Emacs will process its command line so that the dumped Emacs will process its command line
and set up to work with X windows if appropriate. */ and set up to work with X windows if appropriate. */
......
...@@ -40,7 +40,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -40,7 +40,6 @@ Boston, MA 02111-1307, USA. */
char my_edata[] = "End of Emacs initialized data"; char my_edata[] = "End of Emacs initialized data";
#if defined(WINDOWSNT) || defined(CYGWIN)
/* Help unexec locate the end of the .bss area used by Emacs (which /* Help unexec locate the end of the .bss area used by Emacs (which
isn't always a separate section in NT executables). */ isn't always a separate section in NT executables). */
char my_endbss[1]; char my_endbss[1];
...@@ -50,7 +49,6 @@ char my_endbss[1]; ...@@ -50,7 +49,6 @@ char my_endbss[1];
of the bss area used by Emacs. */ of the bss area used by Emacs. */
static char _my_endbss[1]; static char _my_endbss[1];
char * my_endbss_static = _my_endbss; char * my_endbss_static = _my_endbss;
#endif
/* arch-tag: 67e81ab4-e14f-44b2-8875-c0c12252223e /* arch-tag: 67e81ab4-e14f-44b2-8875-c0c12252223e
(do not change this comment) */ (do not change this comment) */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment