On Linux, disable address space randomization
This commit is contained in:
parent
55939b1a4b
commit
e63c8aaa05
|
@ -57,9 +57,8 @@
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_SYS_PERSONALITY_H
|
#if __linux__
|
||||||
#include <sys/personality.h>
|
#include <sys/personality.h>
|
||||||
#define CAN_DO_LINUX32_BUILDS
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_STATVFS
|
#if HAVE_STATVFS
|
||||||
|
@ -1194,7 +1193,7 @@ static string get(const StringPairs & map, const string & key)
|
||||||
static bool canBuildLocally(const string & platform)
|
static bool canBuildLocally(const string & platform)
|
||||||
{
|
{
|
||||||
return platform == settings.thisSystem
|
return platform == settings.thisSystem
|
||||||
#ifdef CAN_DO_LINUX32_BUILDS
|
#if __linux__
|
||||||
|| (platform == "i686-linux" && settings.thisSystem == "x86_64-linux")
|
|| (platform == "i686-linux" && settings.thisSystem == "x86_64-linux")
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
@ -2107,7 +2106,7 @@ void DerivationGoal::initChild()
|
||||||
/* Close all other file descriptors. */
|
/* Close all other file descriptors. */
|
||||||
closeMostFDs(set<int>());
|
closeMostFDs(set<int>());
|
||||||
|
|
||||||
#ifdef CAN_DO_LINUX32_BUILDS
|
#if __linux__
|
||||||
/* Change the personality to 32-bit if we're doing an
|
/* Change the personality to 32-bit if we're doing an
|
||||||
i686-linux build on an x86_64-linux machine. */
|
i686-linux build on an x86_64-linux machine. */
|
||||||
struct utsname utsbuf;
|
struct utsname utsbuf;
|
||||||
|
@ -2115,7 +2114,7 @@ void DerivationGoal::initChild()
|
||||||
if (drv.platform == "i686-linux" &&
|
if (drv.platform == "i686-linux" &&
|
||||||
(settings.thisSystem == "x86_64-linux" ||
|
(settings.thisSystem == "x86_64-linux" ||
|
||||||
(!strcmp(utsbuf.sysname, "Linux") && !strcmp(utsbuf.machine, "x86_64")))) {
|
(!strcmp(utsbuf.sysname, "Linux") && !strcmp(utsbuf.machine, "x86_64")))) {
|
||||||
if (personality(0x0008 | 0x8000000 /* == PER_LINUX32_3GB */) == -1)
|
if (personality(PER_LINUX32_3GB) == -1)
|
||||||
throw SysError("cannot set i686-linux personality");
|
throw SysError("cannot set i686-linux personality");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2125,6 +2124,11 @@ void DerivationGoal::initChild()
|
||||||
int cur = personality(0xffffffff);
|
int cur = personality(0xffffffff);
|
||||||
if (cur != -1) personality(cur | 0x0020000 /* == UNAME26 */);
|
if (cur != -1) personality(cur | 0x0020000 /* == UNAME26 */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Disable address space randomization for improved
|
||||||
|
determinism. */
|
||||||
|
int cur = personality(0xffffffff);
|
||||||
|
if (cur != -1) personality(cur | ADDR_NO_RANDOMIZE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Fill in the environment. */
|
/* Fill in the environment. */
|
||||||
|
|
Loading…
Reference in a new issue