Lines 61-66
Link Here
|
61 |
#include <sys/resource.h> |
61 |
#include <sys/resource.h> |
62 |
#endif |
62 |
#endif |
63 |
|
63 |
|
|
|
64 |
#ifdef HAVE_PERSONALITY_LINUX32 |
65 |
#include <sys/personality.h> |
66 |
#endif |
67 |
|
64 |
#ifndef O_RDWR |
68 |
#ifndef O_RDWR |
65 |
#define O_RDWR 2 |
69 |
#define O_RDWR 2 |
66 |
#endif |
70 |
#endif |
Lines 181-186
Link Here
|
181 |
Tells GC how to save a copy of the stack. */ |
185 |
Tells GC how to save a copy of the stack. */ |
182 |
char *stack_bottom; |
186 |
char *stack_bottom; |
183 |
|
187 |
|
|
|
188 |
/* The address where the heap starts (from the first sbrk (0) call). */ |
189 |
static void *my_heap_start; |
190 |
|
191 |
/* The gap between BSS end and heap start as far as we can tell. */ |
192 |
static unsigned long heap_bss_diff; |
193 |
|
194 |
/* If the gap between BSS end and heap start is larger than this we try to |
195 |
work around it, and if that fails, output a warning in dump-emacs. */ |
196 |
#define MAX_HEAP_BSS_DIFF (1024*1024) |
197 |
|
184 |
#ifdef HAVE_WINDOW_SYSTEM |
198 |
#ifdef HAVE_WINDOW_SYSTEM |
185 |
extern Lisp_Object Vwindow_system; |
199 |
extern Lisp_Object Vwindow_system; |
186 |
#endif /* HAVE_WINDOW_SYSTEM */ |
200 |
#endif /* HAVE_WINDOW_SYSTEM */ |
Lines 692-698
Link Here
|
692 |
free (malloc_state_ptr); |
706 |
free (malloc_state_ptr); |
693 |
} |
707 |
} |
694 |
else |
708 |
else |
695 |
malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; |
709 |
{ |
|
|
710 |
if (my_heap_start == 0) |
711 |
my_heap_start = sbrk (0); |
712 |
malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; |
713 |
} |
696 |
} |
714 |
} |
697 |
|
715 |
|
698 |
void (*__malloc_initialize_hook) () = malloc_initialize_hook; |
716 |
void (*__malloc_initialize_hook) () = malloc_initialize_hook; |
Lines 725-730
Link Here
|
725 |
stack_base = &dummy; |
743 |
stack_base = &dummy; |
726 |
#endif |
744 |
#endif |
727 |
|
745 |
|
|
|
746 |
if (!initialized) |
747 |
{ |
748 |
extern char my_endbss[]; |
749 |
extern char *my_endbss_static; |
750 |
|
751 |
if (my_heap_start == 0) |
752 |
my_heap_start = sbrk (0); |
753 |
|
754 |
heap_bss_diff = (char *)my_heap_start |
755 |
- (my_endbss > my_endbss_static ? my_endbss : my_endbss_static); |
756 |
} |
757 |
|
728 |
#ifdef LINUX_SBRK_BUG |
758 |
#ifdef LINUX_SBRK_BUG |
729 |
__sbrk (1); |
759 |
__sbrk (1); |
730 |
#endif |
760 |
#endif |
Lines 763-768
Link Here
|
763 |
} |
793 |
} |
764 |
} |
794 |
} |
765 |
|
795 |
|
|
|
796 |
#ifdef HAVE_PERSONALITY_LINUX32 |
797 |
/* See if there is a gap between the end of BSS and the heap. |
798 |
In that case, set personality and exec ourself again. */ |
799 |
if (!initialized |
800 |
&& (strcmp (argv[argc-1], "dump") == 0 |
801 |
|| strcmp (argv[argc-1], "bootstrap") == 0) |
802 |
&& heap_bss_diff > MAX_HEAP_BSS_DIFF) |
803 |
{ |
804 |
if (! getenv ("EMACS_HEAP_EXEC")) |
805 |
{ |
806 |
/* Set this so we only do this once. */ |
807 |
putenv("EMACS_HEAP_EXEC=true"); |
808 |
|
809 |
/* A flag to turn off address randomization which is introduced |
810 |
in linux kernel shipped with fedora core 4 */ |
811 |
#define ADD_NO_RANDOMIZE 0x0040000 |
812 |
personality (PER_LINUX32 | ADD_NO_RANDOMIZE); |
813 |
#undef ADD_NO_RANDOMIZE |
814 |
|
815 |
execvp (argv[0], argv); |
816 |
|
817 |
/* If the exec fails, try to dump anyway. */ |
818 |
perror ("execvp"); |
819 |
} |
820 |
} |
821 |
#endif /* HAVE_PERSONALITY_LINUX32 */ |
822 |
|
766 |
/* Map in shared memory, if we are using that. */ |
823 |
/* Map in shared memory, if we are using that. */ |
767 |
#ifdef HAVE_SHM |
824 |
#ifdef HAVE_SHM |
768 |
if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) |
825 |
if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args)) |