Raise RLIMIT_AS to max allowable, so that we can create the large mappings
we need to.  If the hard limit is set to low, then things will fail as
large mmaps fail.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2299 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/stage1.c b/coregrind/stage1.c
index b73c32e..c11a174 100644
--- a/coregrind/stage1.c
+++ b/coregrind/stage1.c
@@ -38,6 +38,7 @@
 #include <signal.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/resource.h>
 
 #include "vg_include.h"
 
@@ -196,6 +197,7 @@
 
 int main(int argc, char **argv)
 {
+   struct rlimit rlim;
    const char *cp = getenv(VALGRINDLIB);
 
    if (cp != NULL)
@@ -205,6 +207,12 @@
 
    our_argc = argc;
 
+   /* Set the address space limit as high as it will go, since we make
+      a lot of very large mappings. */
+   getrlimit(RLIMIT_AS, &rlim);
+   rlim.rlim_cur = rlim.rlim_max;
+   setrlimit(RLIMIT_AS, &rlim);
+
    /* move onto another stack so we can play with the main one */
    ume_go((addr_t)hoops, (addr_t)stack + sizeof(stack));
 }