diff options
| author | Paul Eggert | 2016-07-15 13:07:09 +0200 |
|---|---|---|
| committer | Paul Eggert | 2016-07-15 21:27:05 +0200 |
| commit | e95b023163e96538b15f030b7176b7ec59cf86f5 (patch) | |
| tree | c0ad4b151e8740015949c0aa868deaee14dc8582 /src | |
| parent | 098d29af10a869e65a36804579f16edc49aabcfa (diff) | |
| download | emacs-e95b023163e96538b15f030b7176b7ec59cf86f5.tar.gz emacs-e95b023163e96538b15f030b7176b7ec59cf86f5.zip | |
Port to glibc 2.24 (pre-release) + ppc64
Inspired by a suggestion by Florian Weimer in:
https://sourceware.org/ml/libc-alpha/2016-07/msg00425.html
* configure.ac (HAVE_PERSONALITY_ADDR_NO_RANDOMIZE):
Rename from HAVE_PERSONALITY_LINUX32, and check for
ADDR_NO_RANDOMIZE (the crucial thing) instead of for LINUX32.
All uses changed.
* src/emacs.c (main) [HAVE_PERSONALITY_ADDR_NO_RANDOMIZE]:
Use ADDR_NO_RANDOMIZE from personality.h rather than inventing the
flag ourselves. Just set that flag, rather than also setting the
persona. When doing it, avoid functions like putenv that may
allocate memory.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/emacs.c b/src/emacs.c index bb85733a1f2..b2219844ca0 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -112,7 +112,7 @@ extern void moncontrol (int mode); | |||
| 112 | #include <sys/resource.h> | 112 | #include <sys/resource.h> |
| 113 | #endif | 113 | #endif |
| 114 | 114 | ||
| 115 | #ifdef HAVE_PERSONALITY_LINUX32 | 115 | #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE |
| 116 | #include <sys/personality.h> | 116 | #include <sys/personality.h> |
| 117 | #endif | 117 | #endif |
| 118 | 118 | ||
| @@ -796,24 +796,22 @@ main (int argc, char **argv) | |||
| 796 | dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0 | 796 | dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0 |
| 797 | || strcmp (argv[argc - 1], "bootstrap") == 0); | 797 | || strcmp (argv[argc - 1], "bootstrap") == 0); |
| 798 | 798 | ||
| 799 | #ifdef HAVE_PERSONALITY_LINUX32 | 799 | #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE |
| 800 | if (dumping && ! getenv ("EMACS_HEAP_EXEC")) | 800 | if (dumping) |
| 801 | { | 801 | { |
| 802 | /* Set this so we only do this once. */ | 802 | int pers = personality (0xffffffff); |
| 803 | xputenv ("EMACS_HEAP_EXEC=true"); | 803 | if (! (pers & ADDR_NO_RANDOMIZE) |
| 804 | 804 | && 0 <= personality (pers | ADDR_NO_RANDOMIZE)) | |
| 805 | /* A flag to turn off address randomization which is introduced | 805 | { |
| 806 | in linux kernel shipped with fedora core 4 */ | 806 | /* Address randomization was enabled, but is now disabled. |
| 807 | #define ADD_NO_RANDOMIZE 0x0040000 | 807 | Re-execute Emacs to get a clean slate. */ |
| 808 | personality (PER_LINUX32 | ADD_NO_RANDOMIZE); | 808 | execvp (argv[0], argv); |
| 809 | #undef ADD_NO_RANDOMIZE | ||
| 810 | |||
| 811 | execvp (argv[0], argv); | ||
| 812 | 809 | ||
| 813 | /* If the exec fails, try to dump anyway. */ | 810 | /* If the exec fails, warn and then try without a clean slate. */ |
| 814 | emacs_perror (argv[0]); | 811 | perror (argv[0]); |
| 812 | } | ||
| 815 | } | 813 | } |
| 816 | #endif /* HAVE_PERSONALITY_LINUX32 */ | 814 | #endif |
| 817 | 815 | ||
| 818 | #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) && !defined (CYGWIN) | 816 | #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) && !defined (CYGWIN) |
| 819 | /* Extend the stack space available. Don't do that if dumping, | 817 | /* Extend the stack space available. Don't do that if dumping, |