aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2004-10-20 16:23:30 +0000
committerJan Djärv2004-10-20 16:23:30 +0000
commitdede27921696e4e940c93fa7335066864c93ccfd (patch)
treece72db52bdf71d9dce653075a9565016a81f8f02 /src
parentf17e308a43db0a5bcc847714a79f3334201d415f (diff)
downloademacs-dede27921696e4e940c93fa7335066864c93ccfd.tar.gz
emacs-dede27921696e4e940c93fa7335066864c93ccfd.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/Makefile.in5
-rw-r--r--src/config.in12
-rw-r--r--src/emacs.c65
-rw-r--r--src/lastfile.c2
5 files changed, 86 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5260196d5cd..f1cdd38152d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12004-10-20 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2
3 * emacs.c (my_heap_start, heap_bss_diff, MAX_HEAP_BSS_DIFF):
4 New variables and constant.
5 (main): Calculate heap_bss_diff. If we are dumping and the
6 heap_bss_diff is greater than MAX_HEAP_BSS_DIFF, set PER_LINUX32
7 and exec ourself again.
8 (Fdump_emacs): If heap_bss_diff is greater than MAX_HEAP_BSS_DIFF
9 print a warning.
10
11 * lastfile.c: Make my_endbss and my_endbss_static available on all
12 platforms.
13
14 * Makefile.in (RUN_TEMACS): Remove @SETARCH@.
15 * config.in (HAVE_PERSONALITY_LINUX32): Regenerate.
16
12004-10-19 Luc Teirlinck <teirllm@auburn.edu> 172004-10-19 Luc Teirlinck <teirllm@auburn.edu>
2 18
3 * data.c (Flocal_variable_if_set_p): Doc fix. 19 * data.c (Flocal_variable_if_set_p): Doc fix.
diff --git a/src/Makefile.in b/src/Makefile.in
index f25e0f9d842..deb33730644 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -905,12 +905,7 @@ LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) \
905#define OBJECTS_MACHINE 905#define OBJECTS_MACHINE
906#endif 906#endif
907 907
908#ifdef HAVE_RANDOM_HEAPSTART
909#undef i386
910RUN_TEMACS = @SETARCH@ i386 ./temacs
911#else
912RUN_TEMACS = ./temacs 908RUN_TEMACS = ./temacs
913#endif
914 909
915all: emacs${EXEEXT} OTHER_FILES 910all: emacs${EXEEXT} OTHER_FILES
916 911
diff --git a/src/config.in b/src/config.in
index 49095ca4e5a..136f4ecd55d 100644
--- a/src/config.in
+++ b/src/config.in
@@ -414,6 +414,9 @@ Boston, MA 02111-1307, USA. */
414/* Define to 1 if you have the <nlist.h> header file. */ 414/* Define to 1 if you have the <nlist.h> header file. */
415#undef HAVE_NLIST_H 415#undef HAVE_NLIST_H
416 416
417/* Define to 1 if personality LINUX32 can be set. */
418#undef HAVE_PERSONALITY_LINUX32
419
417/* Define to 1 if you have the png library (-lpng). */ 420/* Define to 1 if you have the png library (-lpng). */
418#undef HAVE_PNG 421#undef HAVE_PNG
419 422
@@ -432,9 +435,6 @@ Boston, MA 02111-1307, USA. */
432/* Define to 1 if you have the `random' function. */ 435/* Define to 1 if you have the `random' function. */
433#undef HAVE_RANDOM 436#undef HAVE_RANDOM
434 437
435/* Define to 1 if this OS randomizes the start address of the heap. */
436#undef HAVE_RANDOM_HEAPSTART
437
438/* Define to 1 if you have the `recvfrom' function. */ 438/* Define to 1 if you have the `recvfrom' function. */
439#undef HAVE_RECVFROM 439#undef HAVE_RECVFROM
440 440
@@ -757,9 +757,9 @@ Boston, MA 02111-1307, USA. */
757/* If using the C implementation of alloca, define if you know the 757/* If using the C implementation of alloca, define if you know the
758 direction of stack growth for your system; otherwise it will be 758 direction of stack growth for your system; otherwise it will be
759 automatically deduced at run-time. 759 automatically deduced at run-time.
760 STACK_DIRECTION > 0 => grows toward higher addresses 760 STACK_DIRECTION > 0 => grows toward higher addresses
761 STACK_DIRECTION < 0 => grows toward lower addresses 761 STACK_DIRECTION < 0 => grows toward lower addresses
762 STACK_DIRECTION = 0 => direction of growth unknown */ 762 STACK_DIRECTION = 0 => direction of growth unknown */
763#undef STACK_DIRECTION 763#undef STACK_DIRECTION
764 764
765/* Define to 1 if you have the ANSI C header files. */ 765/* Define to 1 if you have the ANSI C header files. */
diff --git a/src/emacs.c b/src/emacs.c
index 6ecfdbd4231..bb601ea8643 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -67,6 +67,10 @@ Boston, MA 02111-1307, USA. */
67#include <sys/resource.h> 67#include <sys/resource.h>
68#endif 68#endif
69 69
70#ifdef HAVE_PERSONALITY_LINUX32
71#include <sys/personality.h>
72#endif
73
70#ifndef O_RDWR 74#ifndef O_RDWR
71#define O_RDWR 2 75#define O_RDWR 2
72#endif 76#endif
@@ -192,6 +196,17 @@ int display_arg;
192 Tells GC how to save a copy of the stack. */ 196 Tells GC how to save a copy of the stack. */
193char *stack_bottom; 197char *stack_bottom;
194 198
199/* The address where the heap starts (from the first sbrk (0) call). */
200static void *my_heap_start;
201
202/* The gap between BSS end and heap start as far as we can tell. */
203static unsigned long heap_bss_diff;
204
205/* If the gap between BSS end and heap start is larger than this we try to
206 work around it, and if that fails, output a warning in dump-emacs. */
207#define MAX_HEAP_BSS_DIFF (1024*1024)
208
209
195#ifdef HAVE_WINDOW_SYSTEM 210#ifdef HAVE_WINDOW_SYSTEM
196extern Lisp_Object Vwindow_system; 211extern Lisp_Object Vwindow_system;
197#endif /* HAVE_WINDOW_SYSTEM */ 212#endif /* HAVE_WINDOW_SYSTEM */
@@ -733,7 +748,11 @@ malloc_initialize_hook ()
733 free (malloc_state_ptr); 748 free (malloc_state_ptr);
734 } 749 }
735 else 750 else
736 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; 751 {
752 if (my_heap_start == 0)
753 my_heap_start = sbrk (0);
754 malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
755 }
737} 756}
738 757
739void (*__malloc_initialize_hook) () = malloc_initialize_hook; 758void (*__malloc_initialize_hook) () = malloc_initialize_hook;
@@ -809,6 +828,17 @@ main (argc, argv
809 stack_base = &dummy; 828 stack_base = &dummy;
810#endif 829#endif
811 830
831 if (!initialized)
832 {
833 extern char my_endbss[];
834 extern char *my_endbss_static;
835
836 if (my_heap_start == 0)
837 my_heap_start = sbrk (0);
838
839 heap_bss_diff = (char *)my_heap_start - max (my_endbss, my_endbss_static);
840 }
841
812#ifdef LINUX_SBRK_BUG 842#ifdef LINUX_SBRK_BUG
813 __sbrk (1); 843 __sbrk (1);
814#endif 844#endif
@@ -852,6 +882,28 @@ main (argc, argv
852 } 882 }
853 } 883 }
854 884
885#ifdef HAVE_PERSONALITY_LINUX32
886 /* See if there is a gap between the end of BSS and the heap.
887 In that case, set personality and exec ourself again. */
888 if (!initialized
889 && (strcmp (argv[argc-1], "dump") == 0
890 || strcmp (argv[argc-1], "bootstrap") == 0)
891 && heap_bss_diff > MAX_HEAP_BSS_DIFF)
892 {
893 if (! getenv ("EMACS_HEAP_EXEC"))
894 {
895 /* Set this so we only do this once. */
896 putenv("EMACS_HEAP_EXEC=true");
897 personality (PER_LINUX32);
898 execvp (argv[0], argv);
899
900 /* If the exec fails, try to dump anyway. */
901 perror ("execvp");
902 }
903 }
904#endif /* HAVE_PERSONALITY_LINUX32 */
905
906
855/* Map in shared memory, if we are using that. */ 907/* Map in shared memory, if we are using that. */
856#ifdef HAVE_SHM 908#ifdef HAVE_SHM
857 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) 909 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 if (! noninteractive) 2182 if (! noninteractive)
2131 error ("Dumping Emacs works only in batch mode"); 2183 error ("Dumping Emacs works only in batch mode");
2132 2184
2185 if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
2186 {
2187 fprintf (stderr, "**************************************************\n");
2188 fprintf (stderr, "Warning: Your system has a gap between BSS and the\n");
2189 fprintf (stderr, "heap. This usually means that exec-shield or\n");
2190 fprintf (stderr, "something similar is in effect. The dump may fail\n");
2191 fprintf (stderr, "because of this. See the section about exec-shield\n");
2192 fprintf (stderr, "in etc/PROBLEMS for more information.\n");
2193 fprintf (stderr, "**************************************************\n");
2194 }
2195
2133 /* Bind `command-line-processed' to nil before dumping, 2196 /* Bind `command-line-processed' to nil before dumping,
2134 so that the dumped Emacs will process its command line 2197 so that the dumped Emacs will process its command line
2135 and set up to work with X windows if appropriate. */ 2198 and set up to work with X windows if appropriate. */
diff --git a/src/lastfile.c b/src/lastfile.c
index df678b42876..d6292e30040 100644
--- a/src/lastfile.c
+++ b/src/lastfile.c
@@ -40,7 +40,6 @@ Boston, MA 02111-1307, USA. */
40 40
41char my_edata[] = "End of Emacs initialized data"; 41char my_edata[] = "End of Emacs initialized data";
42 42
43#if defined(WINDOWSNT) || defined(CYGWIN)
44/* Help unexec locate the end of the .bss area used by Emacs (which 43/* Help unexec locate the end of the .bss area used by Emacs (which
45 isn't always a separate section in NT executables). */ 44 isn't always a separate section in NT executables). */
46char my_endbss[1]; 45char my_endbss[1];
@@ -50,7 +49,6 @@ char my_endbss[1];
50 of the bss area used by Emacs. */ 49 of the bss area used by Emacs. */
51static char _my_endbss[1]; 50static char _my_endbss[1];
52char * my_endbss_static = _my_endbss; 51char * my_endbss_static = _my_endbss;
53#endif
54 52
55/* arch-tag: 67e81ab4-e14f-44b2-8875-c0c12252223e 53/* arch-tag: 67e81ab4-e14f-44b2-8875-c0c12252223e
56 (do not change this comment) */ 54 (do not change this comment) */