aboutsummaryrefslogtreecommitdiff
path: root/gdb/windows-nat.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-09-08 08:20:29 -0600
committerTom Tromey <tromey@adacore.com>2022-06-07 09:59:41 -0600
commitbcb9251f029da8dcf360a4f5acfa3b4211c87bb0 (patch)
treec56395b22b1c8ceb3ef8d010c61a4e14c9ee5295 /gdb/windows-nat.c
parent8fea1a81c7d9279a6f91e49ebacfb61e0f8ce008 (diff)
downloadfsf-binutils-gdb-bcb9251f029da8dcf360a4f5acfa3b4211c87bb0.zip
fsf-binutils-gdb-bcb9251f029da8dcf360a4f5acfa3b4211c87bb0.tar.gz
fsf-binutils-gdb-bcb9251f029da8dcf360a4f5acfa3b4211c87bb0.tar.bz2
Allow ASLR to be disabled on Windows
On Windows, it is possible to disable ASLR when creating a process. This patch adds code to do this, and hooks it up to gdb's existing disable-randomization feature. Because the Windows documentation cautions that this isn't available on all versions of Windows, the CreateProcess wrapper function is updated to make the attempt, and then fall back to the current approach if it fails.
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r--gdb/windows-nat.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 262619d..0f9fde9 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -281,6 +281,11 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
int get_windows_debug_event (int pid, struct target_waitstatus *ourstatus);
void do_initial_windows_stuff (DWORD pid, bool attaching);
+
+ bool supports_disable_randomization () override
+ {
+ return disable_randomization_available ();
+ }
};
static windows_nat_target the_windows_nat_target;
@@ -2493,6 +2498,7 @@ windows_nat_target::create_inferior (const char *exec_file,
windows_init_thread_list ();
ret = create_process (args, flags, w32_env,
inferior_cwd != nullptr ? infcwd : nullptr,
+ disable_randomization,
&si, &pi);
if (w32_env)
/* Just free the Win32 environment, if it could be created. */
@@ -2612,6 +2618,7 @@ windows_nat_target::create_inferior (const char *exec_file,
flags, /* start flags */
w32env, /* environment */
inferior_cwd, /* current directory */
+ disable_randomization,
&si,
&pi);
if (tty != INVALID_HANDLE_VALUE)