- /* FIXME: This used to be here. However, I have just removed it
- with no apparent ill effects (it may be that earlier kernels
- started up a process with a different set of traps, or
- something?) Find out what this was meant to do, and reenable it
- or delete it if possible. -- CSR, 2002-07-15 */
- /* SET_FPU_CONTROL_WORD(0x1372|4|8|16|32); no interrupts */
+ if ((major_version == 2
+ /* Some old kernels will apparently lose unsupported personality flags
+ * on exec() */
+ && ((minor_version == 6 && patch_version >= 11)
+ || (minor_version > 6)))
+ || major_version >= 3)
+ {
+ int pers = personality(0xffffffffUL);
+ /* 0x40000 aka. ADDR_NO_RANDOMIZE */
+ if (!(pers & 0x40000)) {
+ int retval = personality(pers | 0x40000);
+ /* Allegedly some Linux kernels (the reported case was
+ * "hardened Linux 2.6.7") won't set the new personality,
+ * but nor will they return -1 for an error. So as a
+ * workaround query the new personality...
+ */
+ int newpers = personality(0xffffffffUL);
+ /* ... and don't re-execute if either the setting resulted
+ * in an error or if the value didn't change. Otherwise
+ * this might result in an infinite loop.
+ */
+ if (retval != -1 && newpers != pers) {
+ /* Use /proc/self/exe instead of trying to figure out
+ * the executable path from PATH and argv[0], since
+ * that's unreliable. We follow the symlink instead of
+ * executing the file directly in order to prevent top
+ * from displaying the name of the process as "exe". */
+ char runtime[PATH_MAX+1];
+ int i = readlink("/proc/self/exe", runtime, PATH_MAX);
+ if (i != -1) {
+ runtime[i] = '\0';
+ execve(runtime, argv, envp);
+ }
+ }
+ /* Either changing the personality or execve() failed. Either
+ * way we might as well continue, and hope that the random
+ * memory maps are ok this time around.
+ */
+ fprintf(stderr, "WARNING: Couldn't re-execute SBCL with the proper personality flags (maybe /proc isn't mounted?). Trying to continue anyway.\n");
+ }
+ }
+ /* Use SSE detector. Recent versions of Linux enable SSE support
+ * on SSE capable CPUs. */
+ /* FIXME: Are there any old versions that does not support SSE? */
+ fast_bzero_pointer = fast_bzero_detect;