aboutsummaryrefslogtreecommitdiff
path: root/gold/options.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-02-26 22:10:32 +0000
committerIan Lance Taylor <iant@google.com>2008-02-26 22:10:32 +0000
commitcd72c291808dbf72aad1603f3c60cd72de62c8f8 (patch)
tree5d4a74840823d0d0ec9cf10d01bf13d4d2fa17cb /gold/options.cc
parent45aa233bdcc27243a2b3e2c699ad0ab59f83901b (diff)
downloadgdb-cd72c291808dbf72aad1603f3c60cd72de62c8f8.zip
gdb-cd72c291808dbf72aad1603f3c60cd72de62c8f8.tar.gz
gdb-cd72c291808dbf72aad1603f3c60cd72de62c8f8.tar.bz2
From Craig Silverstein: implement -z max-page-size and -z
common-page-size.
Diffstat (limited to 'gold/options.cc')
-rw-r--r--gold/options.cc56
1 files changed, 44 insertions, 12 deletions
diff --git a/gold/options.cc b/gold/options.cc
index c5f1edf..8b607af 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -109,8 +109,13 @@ struct options::One_z_option
// The name of the option.
const char* name;
- // The member function in General_options called to record it.
- void (General_options::*set)(bool);
+ // The member function in General_options called to record an option
+ // which does not take an argument.
+ void (General_options::*set_noarg)(bool);
+
+ // The member function in General_options called to record an option
+ // which does take an argument.
+ void (General_options::*set_arg)(const char*);
};
// We have a separate table for --debug options.
@@ -593,7 +598,9 @@ options::Command_line_options::options[] =
GENERAL_ARG('z', NULL,
N_("Subcommands as follows:\n\
-z execstack Mark output as requiring executable stack\n\
- -z noexecstack Mark output as not requiring executable stack"),
+ -z noexecstack Mark output as not requiring executable stack\n\
+ -z max-page-size=SIZE Set maximum page size to SIZE\n\
+ -z common-page-size=SIZE Set common page size to SIZE"),
N_("-z SUBCOMMAND"), ONE_DASH,
&General_options::handle_z_option),
@@ -618,8 +625,10 @@ const int options::Command_line_options::options_size =
const options::One_z_option
options::Command_line_options::z_options[] =
{
- { "execstack", &General_options::set_execstack },
- { "noexecstack", &General_options::set_noexecstack },
+ { "execstack", &General_options::set_execstack, NULL },
+ { "noexecstack", &General_options::set_noexecstack, NULL },
+ { "max-page-size", NULL, &General_options::set_max_page_size },
+ { "common-page-size", NULL, &General_options::set_common_page_size }
};
const int options::Command_line_options::z_options_size =
@@ -670,6 +679,8 @@ General_options::General_options(Script_options* script_options)
thread_count_middle_(0),
thread_count_final_(0),
execstack_(EXECSTACK_FROM_INPUT),
+ max_page_size_(0),
+ common_page_size_(0),
debug_(0),
script_options_(script_options)
{
@@ -731,21 +742,42 @@ General_options::default_target() const
void
General_options::handle_z_option(const char* arg)
{
+ // ARG may be a word, like "noexec", or it may be an option in its
+ // own right, like "max-page-size=SIZE".
+ const char* argarg = strchr(arg, '='); // the argument to the -z argument
+ int arglen;
+ if (argarg)
+ {
+ arglen = argarg - arg;
+ argarg++;
+ }
+ else
+ arglen = strlen(arg);
+
const int z_options_size = options::Command_line_options::z_options_size;
const gold::options::One_z_option* z_options =
gold::options::Command_line_options::z_options;
for (int i = 0; i < z_options_size; ++i)
{
- if (strcmp(arg, z_options[i].name) == 0)
+ if (memcmp(arg, z_options[i].name, arglen) == 0
+ && z_options[i].name[arglen] == '\0')
{
- (this->*(z_options[i].set))(true);
- return;
- }
+ if (z_options[i].set_noarg && argarg)
+ gold::gold_fatal(_("-z subcommand does not take an argument: %s\n"),
+ z_options[i].name);
+ else if (z_options[i].set_arg && !argarg)
+ gold::gold_fatal(_("-z subcommand requires an argument: %s\n"),
+ z_options[i].name);
+ else if (z_options[i].set_arg)
+ (this->*(z_options[i].set_arg))(argarg);
+ else
+ (this->*(z_options[i].set_noarg))(true);
+ return;
+ }
}
- fprintf(stderr, _("%s: unrecognized -z subcommand: %s\n"),
- program_name, arg);
- ::exit(EXIT_FAILURE);
+ gold::gold_fatal(_("%s: unrecognized -z subcommand: %s\n"),
+ program_name, arg);
}
// Handle the --debug option.