From: Ken Brown <address@hidden>
Cc: Angelo Graziosi <address@hidden>
Date: Thu, 1 Sep 2016 15:57:00 -0400
On 9/1/2016 1:16 PM, Eli Zaretskii wrote:
+ However, using the prototype with intptr_t causes GCC to emit
+ warnings. Fortunately, execve is not used in the MinGW build, but
+ the code that references it is still compiled. */
Wouldn't it be easier to prevent that code from being compiled?
It would for the Windows build, but it would add one (actually more,
see below) #ifdef WINDOWSNT into the mainline code. AFAIR, Paul
(CC'ed) wanted to keep those to a minimum, so I preferred not to ifdef
away the code.
I think the following would suffice:
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -146,6 +146,7 @@ disable_address_randomization (void)
}
#endif
+#ifndef WINDOWSNT
/* Execute the program in FILE, with argument vector ARGV and environ
ENVP. Return an error number if unsuccessful. This is like execve
except it reenables ASLR in the executed program if necessary, and
@@ -170,6 +171,7 @@ emacs_exec_file (char const *file, char *const
*argv, char *const *envp)
return err;
}
+#endif /* not WINDOWSNT */
That whole function is not used on Windows, so if we are to do this,
the following fragment of main in emacs.c should also be ifdefed away:
/* True if address randomization interferes with memory allocation. */
# ifdef __PPC64__
bool disable_aslr = true;
# else
bool disable_aslr = dumping;
# endif
if (disable_aslr && disable_address_randomization ())
{
/* Set this so the personality will be reverted before execs
after this one. */
xputenv ("EMACS_HEAP_EXEC=true");
/* Address randomization was enabled, but is now disabled.
Re-execute Emacs to get a clean slate. */
execvp (argv[0], argv);
/* If the exec fails, warn and then try anyway. */
perror (argv[0]);
}
If Paul doesn't mind (nor anyone else), we can certainly do that.
Thanks.