[Lldb-commits] [PATCH] Add process launch --enable-aslr option, tweak handling of flag
Todd Fiala
todd.fiala at gmail.com
Sun Aug 17 22:48:11 PDT 2014
This change modifies the logic used to set the
eLaunchFlagDisableASLR ProcessLaunchInfo setting for inferior process
launching. Now, if 'process launch' is provided with either --disable-aslr
or --enable-aslr, then the launch flag is set accordingly. If niether
--disable-aslr or --enable-aslr are specified, then the setting for
target.disable-aslr is used to determine the setting or clearing of the
eLaunchFlagDisableASLR setting. The target.disable-aslr setting currently
defaults to true, so the default behavior when nothing is specified on the
'process launch' (i.e. 'run' command) is to disable ASLR.
--
-Todd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20140817/c46b4568/attachment.html>
-------------- next part --------------
Index: include/lldb/Target/Process.h
===================================================================
--- include/lldb/Target/Process.h (revision 215871)
+++ include/lldb/Target/Process.h (working copy)
@@ -392,6 +392,7 @@
OptionParsingStarting ()
{
launch_info.Clear();
+ disable_aslr = eLazyBoolCalculate;
}
const OptionDefinition*
@@ -407,6 +408,7 @@
// Instance variables to hold the values for command options.
ProcessLaunchInfo launch_info;
+ lldb_private::LazyBool disable_aslr;
};
//----------------------------------------------------------------------
Index: source/Commands/CommandObjectProcess.cpp
===================================================================
--- source/Commands/CommandObjectProcess.cpp (revision 215871)
+++ source/Commands/CommandObjectProcess.cpp (working copy)
@@ -205,8 +205,19 @@
const char *target_settings_argv0 = target->GetArg0();
- if (target->GetDisableASLR())
+ // Determine whether we will disable ASLR or leave it in the default state (i.e. enabled if the platform supports it).
+ // First check if the process launch options explicitly set it to enabled or disabled. If so, use that setting;
+ // otherwise, use the 'settings target.disable-aslr' setting.
+ bool disable_aslr = false;
+ if (m_options.disable_aslr != eLazyBoolCalculate)
+ disable_aslr = (m_options.disable_aslr == eLazyBoolYes);
+ else
+ disable_aslr = target->GetDisableASLR ();
+
+ if (disable_aslr)
m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
+ else
+ m_options.launch_info.GetFlags().Clear (eLaunchFlagDisableASLR);
if (target->GetDetachOnError())
m_options.launch_info.GetFlags().Set (eLaunchFlagDetachOnError);
Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp (revision 215871)
+++ source/Target/Process.cpp (working copy)
@@ -454,11 +454,15 @@
launch_info.GetArchitecture().SetTriple (option_arg);
break;
- case 'A':
- launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
+ case 'A': // Disable ASLR.
+ disable_aslr = eLazyBoolYes;
break;
-
- case 'c':
+
+ case 'r': // Enable ASLR (i.e. 'r'andomize).
+ disable_aslr = eLazyBoolNo;
+ break;
+
+ case 'c':
if (option_arg && option_arg[0])
launch_info.SetShell (option_arg);
else
@@ -481,6 +485,7 @@
{
{ LLDB_OPT_SET_ALL, false, "stop-at-entry", 's', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."},
{ LLDB_OPT_SET_ALL, false, "disable-aslr", 'A', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Disable address space layout randomization when launching a process."},
+{ LLDB_OPT_SET_ALL, false, "enable-aslr", 'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Enable address space layout randomization when launching a process."},
{ LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
{ LLDB_OPT_SET_ALL, false, "working-dir", 'w', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
{ LLDB_OPT_SET_ALL, false, "arch", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeArchitecture, "Set the architecture for the process to launch when ambiguous."},
More information about the lldb-commits
mailing list