|
|
#endif | #endif |
#endif | #endif |
| |
|
#ifdef HAVE_PERSONALITY_LINUX32 |
|
#include <sys/personality.h> |
|
#endif |
|
|
#ifndef O_RDWR | #ifndef O_RDWR |
#define O_RDWR 2 | #define O_RDWR 2 |
#endif | #endif |
|
|
int xargc; | int xargc; |
#endif /* HAVE_X_WINDOWS */ | #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 | #ifdef USG_SHARED_LIBRARIES |
/* If nonzero, this is the place to put the end of the writable segment | /* If nonzero, this is the place to put the end of the writable segment |
at startup. */ | at startup. */ |
|
|
int skip_args = 0; | int skip_args = 0; |
extern int errno; | extern int errno; |
extern void malloc_warning (); | 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) |
|
{ |
|
if (! 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 */ |
|
#define ADD_NO_RANDOMIZE 0x0040000 |
|
personality (PER_LINUX32 | ADD_NO_RANDOMIZE); |
|
#undef ADD_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. */ | /* Map in shared memory, if we are using that. */ |
#ifdef HAVE_SHM | #ifdef HAVE_SHM |
if (argc > 1 && !strcmp (argv[1], "-nl")) | if (argc > 1 && !strcmp (argv[1], "-nl")) |