>From c14eab222c5208ec0650292c3771a3ee632fdb0d Mon Sep 17 00:00:00 2001 From: Paul Eggert
Date: Sun, 11 Nov 2018 22:18:47 -0800 Subject: [PATCH] Fix dumping on GNU/Linux ppc64le Problem reported by Thomas Fitzsimmons (Bug#33174). * src/emacs.c (main): Adjust to sysdep.c changes. * src/sysdep.c (exec_personality): New static var. (disable_address_randomization): Remove, replacing with ... (maybe_disable_address_randomization): ... this new function. Do not set or use an environment variable; use a command-line argument instead, and set the new static var. Migrate the emacs.c personality-change code to here, where it belongs. (emacs_exec_file): Simplify by using new static var. --- src/emacs.c | 23 +---------------- src/lisp.h | 7 +++-- src/sysdep.c | 73 +++++++++++++++++++++++++++++++++------------------- 3 files changed, 53 insertions(+), 50 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 07df191035..512174d562 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -706,28 +706,7 @@ main (int argc, char **argv) dumping = false; #endif - /* True if address randomization interferes with memory allocation. */ -# ifdef __PPC64__ - bool disable_aslr = true; -# else - bool disable_aslr = dumping; -# endif - - if (disable_aslr && disable_address_randomization () - && !getenv ("EMACS_HEAP_EXEC")) - { - /* Set this so the personality will be reverted before execs - after this one, and to work around an re-exec loop on buggy - kernels (Bug#32083). */ - xputenv ("EMACS_HEAP_EXEC=true"); - - /* Address randomization was enabled, but is now disabled. - Re-execute Emacs to get a clean slate. */ - execvp (argv[0], argv); - - /* If the exec fails, warn and then try anyway. */ - perror (argv[0]); - } + argc = maybe_disable_address_randomization (dumping, argc, argv); #ifndef CANNOT_DUMP might_dump = !initialized; diff --git a/src/lisp.h b/src/lisp.h index eb6762678c..383d61274c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4325,9 +4325,12 @@ struct tty_display_info; /* Defined in sysdep.c. */ #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE -extern bool disable_address_randomization (void); +extern int maybe_disable_address_randomization (bool, int, char **); #else -INLINE bool disable_address_randomization (void) { return false; } +INLINE void +maybe_disable_address_randomization (bool dumping, int argc, char **argv) +{ +} #endif extern int emacs_exec_file (char const *, char *const *, char *const *); extern void init_standard_fds (void); diff --git a/src/sysdep.c b/src/sysdep.c index 7a0c8a8ab8..ddcb594f66 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -150,22 +150,52 @@ static const int baud_convert[] = #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE # include