aboutsummaryrefslogtreecommitdiff
blob: 2cad1eb380a01fd4238f2d7bd2211c70b1a7559f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Prereq: 2007-01-30
diff -ur emacs-18.59-orig/src/ChangeLog emacs-18.59/src/ChangeLog
--- emacs-18.59-orig/src/ChangeLog	2007-01-30 01:00:00.000000000 +0100
+++ emacs-18.59/src/ChangeLog	2008-10-21 15:04:59.000000000 +0200
@@ -1,3 +1,13 @@
+2008-10-21  Ulrich Mueller  <ulm@gentoo.org>
+
+	* emacs.c: Handle gap between end of BSS and heap, backported
+	from Emacs 22. Original changes by Jan Djarv and Masatake YAMATO.
+	This fixes dumping on Linux 2.6.25.
+	(main): Unconditionally set PER_LINUX32 | ADDR_NO_RANDOMIZE
+	and exec ourself again if HAVE_PERSONALITY_LINUX32 is defined.
+
+	* s-linux.h (HAVE_PERSONALITY_LINUX32): Define.
+
 2007-01-30  Ulrich Mueller  <ulm@kph.uni-mainz.de>
 
 	* x11term.c (internal_socket_read): Handle XK_BackSpace key.
diff -ur emacs-18.59-orig/src/emacs.c emacs-18.59/src/emacs.c
--- emacs-18.59-orig/src/emacs.c	2007-01-29 21:47:56.000000000 +0100
+++ emacs-18.59/src/emacs.c	2008-10-21 15:04:59.000000000 +0200
@@ -78,6 +78,13 @@
 #endif
 #endif
 
+#ifdef HAVE_PERSONALITY_LINUX32
+#include <sys/personality.h>
+#ifndef ADDR_NO_RANDOMIZE
+#define ADDR_NO_RANDOMIZE 0x0040000
+#endif
+#endif
+
 #ifndef O_RDWR
 #define O_RDWR 2
 #endif
@@ -242,6 +249,27 @@
   extern int errno;
   extern void malloc_warning ();
 
+#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
+      && !getenv ("EMACS_HEAP_EXEC"))
+    {
+      /* Set this so we only do this once.  */
+      putenv ("EMACS_HEAP_EXEC=true");
+
+      /* A flag to turn off address randomization which is introduced
+	 in linux kernel shipped with fedora core 4 */
+      personality (PER_LINUX32 | ADDR_NO_RANDOMIZE);
+
+      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 (argc > 1 && !strcmp (argv[1], "-nl"))
diff -ur emacs-18.59-orig/src/s-linux.h emacs-18.59/src/s-linux.h
--- emacs-18.59-orig/src/s-linux.h	2007-01-29 21:47:56.000000000 +0100
+++ emacs-18.59/src/s-linux.h	2008-05-11 01:58:40.000000000 +0200
@@ -161,6 +161,7 @@
 #define HAVE_SYS_SIGLIST	/* we have a (non-standard) sys_siglist */
 #define SYS_SIGLIST_DECLARED
 #define HAVE_GETWD		/* cure conflict with getcwd? */
+#define HAVE_PERSONALITY_LINUX32 /* personality LINUX32 can be set */
 
 #define NO_SIOCTL_H		/* don't have sioctl.h */
 #define SYSV_SYSTEM_DIR		/* use dirent.h */