X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gold%2Foptions.cc;h=46d84cf55364cf47c8ee936552c7cc7d2e81e1b3;hb=086a18414ad6c07d0ee79990a971fdc7387af7c1;hp=db655a2e4c6a85d520f0fa5e3315efcaca00a52f;hpb=0daa6f62c88fe4d1dd680b09e855c4b8b7811403;p=deliverable%2Fbinutils-gdb.git diff --git a/gold/options.cc b/gold/options.cc index db655a2e4c..46d84cf553 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -23,10 +23,12 @@ #include "gold.h" #include +#include #include #include #include "filenames.h" #include "libiberty.h" +#include "demangle.h" #include "debug.h" #include "script.h" @@ -36,321 +38,332 @@ namespace gold { -// The information we keep for a single command line option. +General_options +Position_dependent_options::default_options_; -struct options::One_option +namespace options { - // The single character option name, or '\0' if this is only a long - // option. - char short_option; - // The long option name, or NULL if this is only a short option. - const char* long_option; +// This global variable is set up as General_options is constructed. +static std::vector registered_options; - // Description of the option for --help output, or NULL if there is none. - const char* doc; +// These are set up at the same time -- the variables that accept one +// dash, two, or require -z. A single variable may be in more than +// one of thes data structures. +typedef Unordered_map Option_map; +static Option_map* long_options = NULL; +static One_option* short_options[128]; - // How to print the option name in --help output, or NULL to use the - // default. - const char* help_output; - - // Long option dash control. This is ignored if long_option is - // NULL. - enum - { - // Long option normally takes one dash; two dashes are also - // accepted. - ONE_DASH, - // Long option normally takes two dashes; one dash is also - // accepted. - TWO_DASHES, - // Long option always takes two dashes. - EXACTLY_TWO_DASHES - } dash; - - // Function for special handling, or NULL. Returns the number of - // arguments to skip. This will normally be at least 1, but it may - // be 0 if this function changes *argv. ARG points to the location - // in *ARGV where the option starts, which may be helpful for a - // short option. - int (*special)(int argc, char** argv, char *arg, bool long_option, - Command_line*); - - // If this is a position independent option which does not take an - // argument, this is the member function to call to record it. - void (General_options::*general_noarg)(); - - // If this is a position independent function which takes an - // argument, this is the member function to call to record it. - void (General_options::*general_arg)(const char*); - - // If this is a position dependent option which does not take an - // argument, this is the member function to call to record it. - void (Position_dependent_options::*dependent_noarg)(); - - // If this is a position dependent option which takes an argument, - // this is the member function to record it. - void (Position_dependent_options::*dependent_arg)(const char*); - - // Return whether this option takes an argument. - bool - takes_argument() const - { return this->general_arg != NULL || this->dependent_arg != NULL; } -}; - -// We have a separate table for -z options. - -struct options::One_z_option +void +One_option::register_option() { - // The name of the option. - const char* name; + registered_options.push_back(this); - // The member function in General_options called to record it. - void (General_options::*set)(); -}; + // We can't make long_options a static Option_map because we can't + // guarantee that will be initialized before register_option() is + // first called. + if (long_options == NULL) + long_options = new Option_map; -// We have a separate table for --debug options. + // TWO_DASHES means that two dashes are preferred, but one is ok too. + if (!this->longname.empty()) + (*long_options)[this->longname] = this; -struct options::One_debug_option -{ - // The name of the option. - const char* name; - - // The flags to turn on. - unsigned int debug_flags; -}; + const int shortname_as_int = static_cast(this->shortname); + gold_assert(shortname_as_int >= 0 && shortname_as_int < 128); + if (this->shortname != '\0') + short_options[shortname_as_int] = this; +} -class options::Command_line_options +void +One_option::print() const { - public: - static const One_option options[]; - static const int options_size; - static const One_z_option z_options[]; - static const int z_options_size; - static const One_debug_option debug_options[]; - static const int debug_options_size; -}; + bool comma = false; + printf(" "); + int len = 2; + if (this->shortname != '\0') + { + len += printf("-%c", this->shortname); + if (this->helparg) + { + // -z takes long-names only. + gold_assert(this->dashes != DASH_Z); + len += printf(" %s", gettext(this->helparg)); + } + comma = true; + } + if (!this->longname.empty() + && !(this->longname[0] == this->shortname + && this->longname[1] == '\0')) + { + if (comma) + len += printf(", "); + switch (this->dashes) + { + case options::ONE_DASH: case options::EXACTLY_ONE_DASH: + len += printf("-"); + break; + case options::TWO_DASHES: case options::EXACTLY_TWO_DASHES: + len += printf("--"); + break; + case options::DASH_Z: + len += printf("-z "); + break; + default: + gold_unreachable(); + } + len += printf("%s", this->longname.c_str()); + if (this->helparg) + { + // For most options, we print "--frob FOO". But for -z + // we print "-z frob=FOO". + len += printf("%c%s", this->dashes == options::DASH_Z ? '=' : ' ', + gettext(this->helparg)); + } + } -} // End namespace gold. + if (len >= 30) + { + printf("\n"); + len = 0; + } + for (; len < 30; ++len) + std::putchar(' '); -namespace + // TODO: if we're boolean, add " (default)" when appropriate. + printf("%s\n", gettext(this->helpstring)); +} + +void +help() { + printf(_("Usage: %s [options] file...\nOptions:\n"), gold::program_name); -// Recognize input and output target names. The GNU linker accepts -// these with --format and --oformat. This code is intended to be -// minimally compatible. In practice for an ELF target this would be -// the same target as the input files; that name always start with -// "elf". Non-ELF targets would be "srec", "symbolsrec", "tekhex", -// "binary", "ihex". See also -// General_options::default_target_settings. + std::vector::const_iterator it; + for (it = registered_options.begin(); it != registered_options.end(); ++it) + (*it)->print(); +} -gold::General_options::Object_format -string_to_object_format(const char* arg) +// For bool, arg will be NULL (boolean options take no argument); +// we always just set to true. +void +parse_bool(const char*, const char*, bool* retval) { - if (strncmp(arg, "elf", 3) == 0) - return gold::General_options::OBJECT_FORMAT_ELF; - else if (strcmp(arg, "binary") == 0) - return gold::General_options::OBJECT_FORMAT_BINARY; - else - { - gold::gold_error(_("format '%s' not supported " - "(supported formats: elf, binary)"), - arg); - return gold::General_options::OBJECT_FORMAT_ELF; - } + *retval = true; } -// Handle the special -l option, which adds an input file. +void +parse_uint(const char* option_name, const char* arg, int* retval) +{ + char* endptr; + *retval = strtol(arg, &endptr, 0); + if (*endptr != '\0' || retval < 0) + gold_fatal(_("%s: invalid option value (expected an integer): %s"), + option_name, arg); +} -int -library(int argc, char** argv, char* arg, bool long_option, - gold::Command_line* cmdline) +void +parse_uint64(const char* option_name, const char* arg, uint64_t *retval) { - return cmdline->process_l_option(argc, argv, arg, long_option); + char* endptr; + *retval = strtoull(arg, &endptr, 0); + if (*endptr != '\0') + gold_fatal(_("%s: invalid option value (expected an integer): %s"), + option_name, arg); } -// Handle the -R option. Historically the GNU linker made -R a -// synonym for --just-symbols. ELF linkers have traditionally made -R -// a synonym for -rpath. When ELF support was added to the GNU -// linker, -R was changed to switch based on the argument: if the -// argument is an ordinary file, we treat it as --just-symbols, -// otherwise we treat it as -rpath. We need to be compatible with -// this, because existing build scripts rely on it. +void +parse_double(const char* option_name, const char* arg, double* retval) +{ + char* endptr; + *retval = strtod(arg, &endptr); + if (*endptr != '\0') + gold_fatal(_("%s: invalid option value " + "(expected a floating point number): %s"), + option_name, arg); +} -int -handle_r_option(int argc, char** argv, char* arg, bool long_option, - gold::Command_line* cmdline) +void +parse_string(const char* option_name, const char* arg, const char** retval) { - int ret; - const char* val = cmdline->get_special_argument("R", argc, argv, arg, - long_option, &ret); - struct stat s; - if (::stat(val, &s) != 0 || S_ISDIR(s.st_mode)) - cmdline->add_to_rpath(val); - else - cmdline->add_just_symbols_file(val); - return ret; + if (*arg == '\0') + gold_fatal(_("%s: must take a non-empty argument"), option_name); + *retval = arg; } -// Handle the --just-symbols option. +void +parse_optional_string(const char*, const char* arg, const char** retval) +{ + *retval = arg; +} -int -handle_just_symbols_option(int argc, char** argv, char* arg, - bool long_option, gold::Command_line* cmdline) +void +parse_dirlist(const char*, const char* arg, Dir_list* retval) { - int ret; - const char* val = cmdline->get_special_argument("just-symbols", argc, argv, - arg, long_option, &ret); - cmdline->add_just_symbols_file(val); - return ret; + retval->push_back(Search_directory(arg, false)); +} + +void +parse_choices(const char* option_name, const char* arg, const char** retval, + const char* choices[], int num_choices) +{ + for (int i = 0; i < num_choices; i++) + if (strcmp(choices[i], arg) == 0) + { + *retval = arg; + return; + } + + // If we get here, the user did not enter a valid choice, so we die. + std::string choices_list; + for (int i = 0; i < num_choices; i++) + { + choices_list += choices[i]; + if (i != num_choices - 1) + choices_list += ", "; + } + gold_fatal(_("%s: must take one of the following arguments: %s"), + option_name, choices_list.c_str()); } -// Handle the special -T/--script option, which reads a linker script. +} // End namespace options. -int -invoke_script(int argc, char** argv, char* arg, bool long_option, - gold::Command_line* cmdline) +// Define the handler for "special" options (set via DEFINE_special). + +void +General_options::parse_help(const char*, const char*, Command_line*) { - int ret; - const char* script_name = cmdline->get_special_argument("script", argc, argv, - arg, long_option, - &ret); - if (!read_commandline_script(script_name, cmdline)) - gold::gold_fatal(_("unable to parse script file %s"), script_name); - return ret; + options::help(); + ::exit(EXIT_SUCCESS); } -// Handle the special --version-script option, which reads a version script. +void +General_options::parse_version(const char* opt, const char*, Command_line*) +{ + gold::print_version(opt[0] == '-' && opt[1] == 'v'); + ::exit(EXIT_SUCCESS); +} -int -invoke_version_script(int argc, char** argv, char* arg, bool long_option, - gold::Command_line* cmdline) +void +General_options::parse_Bstatic(const char*, const char*, Command_line*) { - int ret; - const char* script_name = cmdline->get_special_argument("version-script", - argc, argv, - arg, long_option, - &ret); - if (!read_version_script(script_name, cmdline)) - gold::gold_fatal(_("unable to parse version script file %s"), script_name); - return ret; + this->set_Bdynamic(false); } -// Handle the special --start-group option. +void +General_options::parse_defsym(const char*, const char* arg, + Command_line* cmdline) +{ + cmdline->script_options().define_symbol(arg); +} -int -start_group(int, char**, char* arg, bool, gold::Command_line* cmdline) +void +General_options::parse_library(const char*, const char* arg, + Command_line* cmdline) { - cmdline->start_group(arg); - return 1; + Input_file_argument file(arg, true, "", false, *this); + cmdline->inputs().add_file(file); } -// Handle the special --end-group option. +void +General_options::parse_R(const char* option, const char* arg, + Command_line* cmdline) +{ + struct stat s; + if (::stat(arg, &s) != 0 || S_ISDIR(s.st_mode)) + this->add_to_rpath(arg); + else + this->parse_just_symbols(option, arg, cmdline); +} -int -end_group(int, char**, char* arg, bool, gold::Command_line* cmdline) +void +General_options::parse_just_symbols(const char*, const char* arg, + Command_line* cmdline) { - cmdline->end_group(arg); - return 1; + Input_file_argument file(arg, false, "", true, *this); + cmdline->inputs().add_file(file); } -// Report usage information for ld --help, and exit. +void +General_options::parse_static(const char*, const char*, Command_line*) +{ + this->set_static(true); +} -int -help(int, char**, char*, bool, gold::Command_line*) +void +General_options::parse_script(const char*, const char* arg, + Command_line* cmdline) { - printf(_("Usage: %s [options] file...\nOptions:\n"), gold::program_name); + if (!read_commandline_script(arg, cmdline)) + gold::gold_fatal(_("unable to parse script file %s"), arg); +} - const int options_size = gold::options::Command_line_options::options_size; - const gold::options::One_option* options = - gold::options::Command_line_options::options; - for (int i = 0; i < options_size; ++i) - { - if (options[i].doc == NULL) - continue; +void +General_options::parse_version_script(const char*, const char* arg, + Command_line* cmdline) +{ + if (!read_version_script(arg, cmdline)) + gold::gold_fatal(_("unable to parse version script file %s"), arg); +} - printf(" "); - int len = 2; - bool comma = false; +void +General_options::parse_start_group(const char*, const char*, + Command_line* cmdline) +{ + cmdline->inputs().start_group(); +} - int j = i; - do - { - if (options[j].help_output != NULL) - { - if (comma) - { - printf(", "); - len += 2; - } - printf(options[j].help_output); - len += std::strlen(options[j].help_output); - comma = true; - } - else - { - if (options[j].short_option != '\0') - { - if (comma) - { - printf(", "); - len += 2; - } - printf("-%c", options[j].short_option); - len += 2; - comma = true; - } - - if (options[j].long_option != NULL) - { - if (comma) - { - printf(", "); - len += 2; - } - if (options[j].dash == gold::options::One_option::ONE_DASH) - { - printf("-"); - ++len; - } - else - { - printf("--"); - len += 2; - } - printf("%s", options[j].long_option); - len += std::strlen(options[j].long_option); - comma = true; - } - } - ++j; - } - while (j < options_size && options[j].doc == NULL); +void +General_options::parse_end_group(const char*, const char*, + Command_line* cmdline) +{ + cmdline->inputs().end_group(); +} - if (len >= 30) - { - printf("\n"); - len = 0; - } - for (; len < 30; ++len) - std::putchar(' '); +} // End namespace gold. - std::puts(options[i].doc); - } +namespace +{ - ::exit(EXIT_SUCCESS); +void +usage() +{ + fprintf(stderr, + _("%s: use the --help option for usage information\n"), + gold::program_name); + ::exit(EXIT_FAILURE); +} - return 0; +void +usage(const char* msg, const char *opt) +{ + fprintf(stderr, + _("%s: %s: %s\n"), + gold::program_name, opt, msg); + usage(); } -// Report version information. +// Recognize input and output target names. The GNU linker accepts +// these with --format and --oformat. This code is intended to be +// minimally compatible. In practice for an ELF target this would be +// the same target as the input files; that name always start with +// "elf". Non-ELF targets would be "srec", "symbolsrec", "tekhex", +// "binary", "ihex". -int -version(int, char**, char* opt, bool, gold::Command_line*) +gold::General_options::Object_format +string_to_object_format(const char* arg) { - gold::print_version(opt[0] == 'v' && opt[1] == '\0'); - ::exit(EXIT_SUCCESS); - return 0; + if (strncmp(arg, "elf", 3) == 0) + return gold::General_options::OBJECT_FORMAT_ELF; + else if (strcmp(arg, "binary") == 0) + return gold::General_options::OBJECT_FORMAT_BINARY; + else + { + gold::gold_error(_("format '%s' not supported; treating as elf " + "(supported formats: elf, binary)"), + arg); + return gold::General_options::OBJECT_FORMAT_ELF; + } } // If the default sysroot is relocatable, try relocating it based on @@ -360,12 +373,12 @@ char* get_relative_sysroot(const char* from) { char* path = make_relative_prefix(gold::program_name, from, - TARGET_SYSTEM_ROOT); + TARGET_SYSTEM_ROOT); if (path != NULL) { struct stat s; if (::stat(path, &s) == 0 && S_ISDIR(s.st_mode)) - return path; + return path; free(path); } @@ -373,389 +386,197 @@ get_relative_sysroot(const char* from) } // Return the default sysroot. This is set by the --with-sysroot -// option to configure. +// option to configure. Note we do not free the return value of +// get_relative_sysroot, which is a small memory leak, but is +// necessary since we store this pointer directly in General_options. -std::string +const char* get_default_sysroot() { const char* sysroot = TARGET_SYSTEM_ROOT; if (*sysroot == '\0') - return ""; + return NULL; if (TARGET_SYSTEM_ROOT_RELOCATABLE) { - char* path = get_relative_sysroot (BINDIR); + char* path = get_relative_sysroot(BINDIR); if (path == NULL) - path = get_relative_sysroot (TOOLBINDIR); + path = get_relative_sysroot(TOOLBINDIR); if (path != NULL) - { - std::string ret = path; - free(path); - return ret; - } + return path; } return sysroot; } -} // End anonymous namespace. - -namespace gold -{ - -// Helper macros used to specify the options. We could also do this -// using constructors, but then g++ would generate code to initialize -// the array. We want the array to be initialized statically so that -// we get better startup time. - -#define GENERAL_NOARG(short_option, long_option, doc, help, dash, func) \ - { short_option, long_option, doc, help, options::One_option::dash, \ - NULL, func, NULL, NULL, NULL } -#define GENERAL_ARG(short_option, long_option, doc, help, dash, func) \ - { short_option, long_option, doc, help, options::One_option::dash, \ - NULL, NULL, func, NULL, NULL } -#define POSDEP_NOARG(short_option, long_option, doc, help, dash, func) \ - { short_option, long_option, doc, help, options::One_option::dash, \ - NULL, NULL, NULL, func, NULL } -#define POSDEP_ARG(short_option, long_option, doc, help, dash, func) \ - { short_option, long_option, doc, help, options::One_option::dash, \ - NULL, NULL, NULL, NULL, func } -#define SPECIAL(short_option, long_option, doc, help, dash, func) \ - { short_option, long_option, doc, help, options::One_option::dash, \ - func, NULL, NULL, NULL, NULL } - -// Here is the actual list of options which we accept. - -const options::One_option -options::Command_line_options::options[] = -{ - GENERAL_NOARG('\0', "allow-shlib-undefined", - N_("Allow unresolved references in shared libraries"), - NULL, TWO_DASHES, - &General_options::set_allow_shlib_undefined), - GENERAL_NOARG('\0', "no-allow-shlib-undefined", - N_("Do not allow unresolved references in shared libraries"), - NULL, TWO_DASHES, - &General_options::set_no_allow_shlib_undefined), - POSDEP_NOARG('\0', "as-needed", - N_("Only set DT_NEEDED for dynamic libs if used"), - NULL, TWO_DASHES, &Position_dependent_options::set_as_needed), - POSDEP_NOARG('\0', "no-as-needed", - N_("Always DT_NEEDED for dynamic libs (default)"), - NULL, TWO_DASHES, &Position_dependent_options::clear_as_needed), - POSDEP_NOARG('\0', "Bdynamic", - N_("-l searches for shared libraries"), - NULL, ONE_DASH, - &Position_dependent_options::set_dynamic_search), - POSDEP_NOARG('\0', "Bstatic", - N_("-l does not search for shared libraries"), - NULL, ONE_DASH, - &Position_dependent_options::set_static_search), - GENERAL_NOARG('\0', "Bsymbolic", N_("Bind defined symbols locally"), - NULL, ONE_DASH, &General_options::set_symbolic), - POSDEP_ARG('b', "format", N_("Set input format (elf, binary)"), - N_("-b FORMAT, --format FORMAT"), TWO_DASHES, - &Position_dependent_options::set_input_format), -#ifdef HAVE_ZLIB_H -# define ZLIB_STR ",zlib" -#else -# define ZLIB_STR "" -#endif - GENERAL_ARG('\0', "compress-debug-sections", - N_("Compress .debug_* sections in the output file " - "(default is none)"), - N_("--compress-debug-sections=[none" ZLIB_STR "]"), - TWO_DASHES, - &General_options::set_compress_debug_sections), - GENERAL_ARG('\0', "defsym", N_("Define a symbol"), - N_("--defsym SYMBOL=EXPRESSION"), TWO_DASHES, - &General_options::define_symbol), - GENERAL_NOARG('\0', "demangle", N_("Demangle C++ symbols in log messages"), - NULL, TWO_DASHES, &General_options::set_demangle), - GENERAL_NOARG('\0', "no-demangle", - N_("Do not demangle C++ symbols in log messages"), - NULL, TWO_DASHES, &General_options::clear_demangle), - GENERAL_NOARG('\0', "detect-odr-violations", - N_("Try to detect violations of the One Definition Rule"), - NULL, TWO_DASHES, &General_options::set_detect_odr_violations), - GENERAL_ARG('e', "entry", N_("Set program start address"), - N_("-e ADDRESS, --entry ADDRESS"), TWO_DASHES, - &General_options::set_entry), - GENERAL_NOARG('E', "export-dynamic", N_("Export all dynamic symbols"), - NULL, TWO_DASHES, &General_options::set_export_dynamic), - GENERAL_NOARG('\0', "eh-frame-hdr", N_("Create exception frame header"), - NULL, TWO_DASHES, &General_options::set_create_eh_frame_hdr), - GENERAL_ARG('h', "soname", N_("Set shared library name"), - N_("-h FILENAME, -soname FILENAME"), ONE_DASH, - &General_options::set_soname), - GENERAL_ARG('I', "dynamic-linker", N_("Set dynamic linker path"), - N_("-I PROGRAM, --dynamic-linker PROGRAM"), TWO_DASHES, - &General_options::set_dynamic_linker), - SPECIAL('l', "library", N_("Search for library LIBNAME"), - N_("-lLIBNAME, --library LIBNAME"), TWO_DASHES, - &library), - GENERAL_ARG('L', "library-path", N_("Add directory to search path"), - N_("-L DIR, --library-path DIR"), TWO_DASHES, - &General_options::add_to_search_path), - GENERAL_ARG('m', NULL, N_("Ignored for compatibility"), NULL, ONE_DASH, - &General_options::ignore), - GENERAL_ARG('o', "output", N_("Set output file name"), - N_("-o FILE, --output FILE"), TWO_DASHES, - &General_options::set_output_file_name), - GENERAL_ARG('O', NULL, N_("Optimize output file size"), - N_("-O level"), ONE_DASH, - &General_options::set_optimization_level), - GENERAL_ARG('\0', "oformat", N_("Set output format (only binary supported)"), - N_("--oformat FORMAT"), EXACTLY_TWO_DASHES, - &General_options::set_output_format), - GENERAL_NOARG('r', NULL, N_("Generate relocatable output"), NULL, - ONE_DASH, &General_options::set_relocatable), - // -R really means -rpath, but can mean --just-symbols for - // compatibility with GNU ld. -rpath is always -rpath, so we list - // it separately. - SPECIAL('R', NULL, N_("Add DIR to runtime search path"), - N_("-R DIR"), ONE_DASH, &handle_r_option), - GENERAL_ARG('\0', "rpath", NULL, N_("-rpath DIR"), ONE_DASH, - &General_options::add_to_rpath), - SPECIAL('\0', "just-symbols", N_("Read only symbol values from file"), - N_("-R FILE, --just-symbols FILE"), TWO_DASHES, - &handle_just_symbols_option), - GENERAL_ARG('\0', "rpath-link", - N_("Add DIR to link time shared library search path"), - N_("--rpath-link DIR"), TWO_DASHES, - &General_options::add_to_rpath_link), - GENERAL_NOARG('s', "strip-all", N_("Strip all symbols"), NULL, - TWO_DASHES, &General_options::set_strip_all), - GENERAL_NOARG('\0', "strip-debug-gdb", - N_("Strip debug symbols that are unused by gdb " - "(at least versions <= 6.7)"), - NULL, TWO_DASHES, &General_options::set_strip_debug_gdb), - // This must come after -Sdebug since it's a prefix of it. - GENERAL_NOARG('S', "strip-debug", N_("Strip debugging information"), NULL, - TWO_DASHES, &General_options::set_strip_debug), - GENERAL_NOARG('\0', "shared", N_("Generate shared library"), - NULL, ONE_DASH, &General_options::set_shared), - GENERAL_NOARG('\0', "static", N_("Do not link against shared libraries"), - NULL, ONE_DASH, &General_options::set_static), - GENERAL_NOARG('\0', "stats", N_("Print resource usage statistics"), - NULL, TWO_DASHES, &General_options::set_stats), - GENERAL_ARG('\0', "sysroot", N_("Set target system root directory"), - N_("--sysroot DIR"), TWO_DASHES, &General_options::set_sysroot), - GENERAL_ARG('\0', "Ttext", N_("Set the address of the .text section"), - N_("-Ttext ADDRESS"), ONE_DASH, - &General_options::set_text_segment_address), - // This must come after -Ttext since it's a prefix of it. - SPECIAL('T', "script", N_("Read linker script"), - N_("-T FILE, --script FILE"), TWO_DASHES, - &invoke_script), - SPECIAL('\0', "version-script", N_("Read version script"), - N_("--version-script FILE"), TWO_DASHES, - &invoke_version_script), - GENERAL_NOARG('\0', "threads", N_("Run the linker multi-threaded"), - NULL, TWO_DASHES, &General_options::set_threads), - GENERAL_NOARG('\0', "no-threads", N_("Do not run the linker multi-threaded"), - NULL, TWO_DASHES, &General_options::clear_threads), - GENERAL_ARG('\0', "thread-count", N_("Number of threads to use"), - N_("--thread-count COUNT"), TWO_DASHES, - &General_options::set_thread_count), - GENERAL_ARG('\0', "thread-count-initial", - N_("Number of threads to use in initial pass"), - N_("--thread-count-initial COUNT"), TWO_DASHES, - &General_options::set_thread_count_initial), - GENERAL_ARG('\0', "thread-count-middle", - N_("Number of threads to use in middle pass"), - N_("--thread-count-middle COUNT"), TWO_DASHES, - &General_options::set_thread_count_middle), - GENERAL_ARG('\0', "thread-count-final", - N_("Number of threads to use in final pass"), - N_("--thread-count-final COUNT"), TWO_DASHES, - &General_options::set_thread_count_final), - POSDEP_NOARG('\0', "whole-archive", - N_("Include all archive contents"), - NULL, TWO_DASHES, - &Position_dependent_options::set_whole_archive), - POSDEP_NOARG('\0', "no-whole-archive", - N_("Include only needed archive contents"), - NULL, TWO_DASHES, - &Position_dependent_options::clear_whole_archive), - - 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"), - N_("-z SUBCOMMAND"), ONE_DASH, - &General_options::handle_z_option), - - SPECIAL('(', "start-group", N_("Start a library search group"), NULL, - TWO_DASHES, &start_group), - SPECIAL(')', "end-group", N_("End a library search group"), NULL, - TWO_DASHES, &end_group), - SPECIAL('\0', "help", N_("Report usage information"), NULL, - TWO_DASHES, &help), - SPECIAL('v', "version", N_("Report version information"), NULL, - TWO_DASHES, &version), - GENERAL_ARG('\0', "debug", N_("Turn on debugging (all,task,script)"), - N_("--debug=TYPE"), TWO_DASHES, - &General_options::handle_debug_option) -}; - -const int options::Command_line_options::options_size = - sizeof (options) / sizeof (options[0]); - -// The -z options. - -const options::One_z_option -options::Command_line_options::z_options[] = +// Parse a long option. Such options have the form +// <-|-->