[patch] Disable child VMA randomizations
Daniel Jacobowitz
drow@false.org
Thu Jun 26 15:52:00 GMT 2008
Please also add the new commands to NEWS.
On Sun, Jun 08, 2008 at 06:43:31PM +0200, Jan Kratochvil wrote:
> @@ -149,6 +156,19 @@ show_debug_linux_nat_async (struct ui_fi
> value);
> }
>
> +#ifdef HAVE_PERSONALITY
> +static int disable_randomization = 1;
> +
> +static void
> +show_disable_randomization (struct ui_file *file, int from_tty,
> + struct cmd_list_element *c, const char *value)
> +{
> + fprintf_filtered (file, _("\
> +Disabling randomization of debuggee's virtual address space is %s.\n"),
> + value);
> +}
> +#endif /* HAVE_PERSONALITY */
> +
> static int linux_parent_pid;
>
> struct simple_pid_list
I think it would be better to register the command unconditionally,
but only call personality if it is available. I'd like to keep
conditionally compiled code to a minimum.
> + warning (_("Error setting the enabled disable-randomization: %s"),
Error disabling address space randomization:
> + safe_strerror (errno));
> + }
> +#endif /* HAVE_PERSONALITY */
> +
> linux_ops->to_create_inferior (exec_file, allargs, env, from_tty);
>
> +#ifdef HAVE_PERSONALITY
> + if (personality_set)
> + {
> + errno = 0;
> + personality (personality_orig);
> + if (errno != 0)
> + warning (_("Problem restoring the disable-randomization state: %s"),
Error restoring address space randomization:
> +When this mode is on (which is the default), the randomization of\n\
> +the virtual address space is disabled. Standalone programs run with the\n\
> +randomization enabled by default on some platforms."),
You don't need "the" before randomization in this case (two places).
> +misusing it. Still even a prelinked shared library can get loaded a a new
at a
> + gdb_test_multiple "continue" $testname {
> + -re "address = (0x\[0-9a-f\]*).*Program exited normally..*$gdb_prompt $" {
> + pass $testname
> + return $expect_out(1,string)
> + }
Please set a breakpoint and use GDB to print out the variable, instead
of relying on printf; some test configurations don't work with stdio.
They probably won't work with this test anyway, but no reason to
complicate things.
> +gdb_test "set disable-randomization off"
> +set addr1 [address_get "randomized first address"]
> +set addr2 [address_get "randomized second address"]
> +set test "randomized addresses should not match"
> +if {$addr1 eq $addr2} {
> + fail $test
> +} else {
> + pass $test
> +}
This test will only pass if the system supports address randomization
and has it enabled. I don't know about you, but the first thing I do
on a new developer system is turn it off...
--
Daniel Jacobowitz
CodeSourcery
More information about the Gdb-patches
mailing list