aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/18.59/05_all_bss-heap-gap.patch100
-rw-r--r--emacs/21.4/17_all_bss-heap-gap.patch111
2 files changed, 44 insertions, 167 deletions
diff --git a/emacs/18.59/05_all_bss-heap-gap.patch b/emacs/18.59/05_all_bss-heap-gap.patch
index 215e951..2cad1eb 100644
--- a/emacs/18.59/05_all_bss-heap-gap.patch
+++ b/emacs/18.59/05_all_bss-heap-gap.patch
@@ -1,20 +1,15 @@
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-05-11 02:12:37.000000000 +0200
-@@ -1,3 +1,18 @@
-+2008-05-11 Ulrich Mueller <ulm@gentoo.org>
++++ 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.
-+ (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 ADD_NO_RANDOMIZE and exec ourself again.
-+
-+ * lastfile.c: (my_endbss, my_endbss_static) New variables.
++ (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.
+
@@ -23,98 +18,49 @@ diff -ur emacs-18.59-orig/src/ChangeLog emacs-18.59/src/ChangeLog
* 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-05-11 01:49:58.000000000 +0200
-@@ -78,6 +78,10 @@
++++ 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
-@@ -110,6 +114,16 @@
- int xargc;
- #endif /* HAVE_X_WINDOWS */
-
-+/* 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 USG_SHARED_LIBRARIES
- /* If nonzero, this is the place to put the end of the writable segment
- at startup. */
-@@ -241,6 +255,45 @@
- int skip_args = 0;
+@@ -242,6 +249,27 @@
extern int errno;
extern void malloc_warning ();
-+ extern char *sbrk ();
-+
-+ 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
-+ - (my_endbss > my_endbss_static ? my_endbss : my_endbss_static);
-+ }
-+
+
+#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
-+ && heap_bss_diff > MAX_HEAP_BSS_DIFF)
++ && !getenv ("EMACS_HEAP_EXEC"))
+ {
-+ if (! getenv ("EMACS_HEAP_EXEC"))
-+ {
-+ /* Set this so we only do this once. */
-+ putenv("EMACS_HEAP_EXEC=true");
++ /* 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 */
-+#define ADD_NO_RANDOMIZE 0x0040000
-+ personality (PER_LINUX32 | ADD_NO_RANDOMIZE);
-+#undef ADD_NO_RANDOMIZE
++ /* 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);
++ execvp (argv[0], argv);
+
-+ /* If the exec fails, try to dump anyway. */
-+ perror ("execvp");
-+ }
++ /* 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
-diff -ur emacs-18.59-orig/src/lastfile.c emacs-18.59/src/lastfile.c
---- emacs-18.59-orig/src/lastfile.c 1991-03-31 00:05:55.000000000 +0100
-+++ emacs-18.59/src/lastfile.c 2008-05-11 01:52:45.000000000 +0200
-@@ -41,3 +41,13 @@
- #endif
-
- char my_edata = 0;
-+
-+/* Help unexec locate the end of the .bss area used by Emacs (which
-+ isn't always a separate section in NT executables). */
-+char my_endbss[1];
-+
-+/* The Alpha MSVC linker globally segregates all static and public bss
-+ data, so we must take both into account to determine the true extent
-+ of the bss area used by Emacs. */
-+static char _my_endbss[1];
-+char * my_endbss_static = _my_endbss;
+ 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
diff --git a/emacs/21.4/17_all_bss-heap-gap.patch b/emacs/21.4/17_all_bss-heap-gap.patch
index c479e81..c2e0ebc 100644
--- a/emacs/21.4/17_all_bss-heap-gap.patch
+++ b/emacs/21.4/17_all_bss-heap-gap.patch
@@ -1,6 +1,12 @@
http://bugs.gentoo.org/221281
temacs segfaults in dump-emacs under Linux 2.6.25
-Patch backported from Emacs 22, it comprises the following changes:
+Patch backported from Emacs 22 and upstream bug 900.
+It comprises parts of the following changes:
+
+2008-10-21 Jan Djärv <jan.h.d@swipnet.se>
+
+ * emacs.c (main): Unconditionally set PER_LINUX32 and exec
+ temacs when dumping if HAVE_PERSONALITY_LINUX32 is defined
2005-07-01 Masatake YAMATO <jet@gyve.org>
@@ -8,15 +14,6 @@ Patch backported from Emacs 22, it comprises the following changes:
2004-10-20 Jan Djärv <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.
-
- * lastfile.c: Make my_endbss and my_endbss_static available on all
- platforms.
-
* configure.in (HAVE_PERSONALITY_LINUX32): New test if PER_LINUX32
can be set.
@@ -53,67 +50,21 @@ Patch backported from Emacs 22, it comprises the following changes:
#undef HAVE_LIBPTHREADS
--- emacs-21.4-orig/src/emacs.c 2002-08-29 21:27:07.000000000 +0200
+++ emacs-21.4/src/emacs.c 2008-05-11 00:26:38.000000000 +0200
-@@ -61,6 +61,10 @@
+@@ -61,6 +61,13 @@
#include <sys/resource.h>
#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
-@@ -181,6 +185,16 @@
- 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 */
-@@ -692,7 +706,11 @@
- free (malloc_state_ptr);
- }
- 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;
-@@ -725,6 +743,18 @@
- 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
-+ - (my_endbss > my_endbss_static ? my_endbss : my_endbss_static);
-+ }
-+
- #ifdef LINUX_SBRK_BUG
- __sbrk (1);
- #endif
-@@ -763,6 +793,33 @@
+@@ -763,6 +770,28 @@
}
}
@@ -123,42 +74,22 @@ Patch backported from Emacs 22, it comprises the following changes:
+ if (!initialized
+ && (strcmp (argv[argc-1], "dump") == 0
+ || strcmp (argv[argc-1], "bootstrap") == 0)
-+ && heap_bss_diff > MAX_HEAP_BSS_DIFF)
++ && !getenv ("EMACS_HEAP_EXEC"))
+ {
-+ if (! getenv ("EMACS_HEAP_EXEC"))
-+ {
-+ /* Set this so we only do this once. */
-+ putenv("EMACS_HEAP_EXEC=true");
++ /* 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 */
-+#define ADD_NO_RANDOMIZE 0x0040000
-+ personality (PER_LINUX32 | ADD_NO_RANDOMIZE);
-+#undef ADD_NO_RANDOMIZE
++ /* 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);
++ execvp (argv[0], argv);
+
-+ /* If the exec fails, try to dump anyway. */
-+ perror ("execvp");
-+ }
++ /* 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))
---- emacs-21.4-orig/src/lastfile.c 1999-01-17 20:16:08.000000000 +0100
-+++ emacs-21.4/src/lastfile.c 2008-05-11 00:01:55.000000000 +0200
-@@ -40,7 +40,6 @@
-
- char my_edata[] = "End of Emacs initialized data";
-
--#ifdef WINDOWSNT
- /* Help unexec locate the end of the .bss area used by Emacs (which
- isn't always a separate section in NT executables). */
- char my_endbss[1];
-@@ -50,4 +49,3 @@
- of the bss area used by Emacs. */
- static char _my_endbss[1];
- char * my_endbss_static = _my_endbss;
--#endif