X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gold%2Foptions.cc;h=d92394120a54f2cafdb40274c574688929b3f0c8;hb=15a7492a25589fe5721322b73f05a4eeb8899a6f;hp=6b49459e44329d4727517ab99b99b1419ed6d7af;hpb=fd834e57ffce2f5dbe3443f034e68cebd63ee89a;p=external%2Fbinutils.git diff --git a/gold/options.cc b/gold/options.cc index 6b49459..d923941 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -1,7 +1,6 @@ // options.c -- handle command line options for gold -// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2013 -// Free Software Foundation, Inc. +// Copyright (C) 2006-2019 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -147,8 +146,10 @@ One_option::print() const for (; len < 30; ++len) std::putchar(' '); - // TODO: if we're boolean, add " (default)" when appropriate. - printf("%s\n", gettext(this->helpstring)); + printf("%s", gettext(this->helpstring)); + if (this->is_default) + printf(" (%s)", _("default")); + printf("\n"); } void @@ -347,6 +348,27 @@ General_options::parse_defsym(const char*, const char* arg, } void +General_options::parse_discard_all(const char*, const char*, + Command_line*) +{ + this->discard_locals_ = DISCARD_ALL; +} + +void +General_options::parse_discard_locals(const char*, const char*, + Command_line*) +{ + this->discard_locals_ = DISCARD_LOCALS; +} + +void +General_options::parse_discard_none(const char*, const char*, + Command_line*) +{ + this->discard_locals_ = DISCARD_NONE; +} + +void General_options::parse_incremental(const char*, const char*, Command_line*) { @@ -426,7 +448,6 @@ General_options::parse_library(const char*, const char* arg, cmdline->inputs().add_file(file); } -#ifdef ENABLE_PLUGINS void General_options::parse_plugin(const char*, const char* arg, Command_line*) @@ -442,7 +463,6 @@ General_options::parse_plugin_opt(const char*, const char* arg, { this->add_plugin_option(arg); } -#endif // ENABLE_PLUGINS void General_options::parse_R(const char* option, const char* arg, @@ -667,6 +687,20 @@ General_options::string_to_object_format(const char* arg) } } +const char* +General_options::object_format_to_string(General_options::Object_format fmt) +{ + switch (fmt) + { + case General_options::OBJECT_FORMAT_ELF: + return "elf"; + case General_options::OBJECT_FORMAT_BINARY: + return "binary"; + default: + gold_unreachable(); + } +} + void General_options::parse_fix_v4bx(const char*, const char*, Command_line*) @@ -693,6 +727,39 @@ General_options::parse_EL(const char*, const char*, Command_line*) this->endianness_ = ENDIANNESS_LITTLE; } +void +General_options::copy_from_posdep_options( + const Position_dependent_options& posdep) +{ + this->set_as_needed(posdep.as_needed()); + this->set_Bdynamic(posdep.Bdynamic()); + this->set_format( + General_options::object_format_to_string(posdep.format_enum())); + this->set_whole_archive(posdep.whole_archive()); + this->set_incremental_disposition(posdep.incremental_disposition()); +} + +void +General_options::parse_push_state(const char*, const char*, Command_line*) +{ + Position_dependent_options* posdep = new Position_dependent_options(*this); + this->options_stack_.push_back(posdep); +} + +void +General_options::parse_pop_state(const char*, const char*, Command_line*) +{ + if (this->options_stack_.empty()) + { + gold::gold_error(_("unbalanced --push-state/--pop-state")); + return; + } + Position_dependent_options* posdep = this->options_stack_.back(); + this->options_stack_.pop_back(); + this->copy_from_posdep_options(*posdep); + delete posdep; +} + } // End namespace gold. namespace @@ -856,7 +923,7 @@ parse_short_option(int argc, const char** argv, int pos_in_argv_i, // We handle -z as a special case. static gold::options::One_option dash_z("", gold::options::DASH_Z, 'z', "", NULL, "Z-OPTION", false, - NULL); + NULL, false); gold::options::One_option* retval = NULL; if (this_argv[pos_in_argv_i] == 'z') retval = &dash_z; @@ -928,7 +995,9 @@ General_options::General_options() symbols_to_retain_(), section_starts_(), fix_v4bx_(FIX_V4BX_NONE), - endianness_(ENDIANNESS_NOT_SET) + endianness_(ENDIANNESS_NOT_SET), + discard_locals_(DISCARD_SEC_MERGE), + orphan_handling_enum_(ORPHAN_PLACE) { // Turn off option registration once construction is complete. gold::options::ready_to_register = false; @@ -1087,6 +1156,19 @@ General_options::finalize() this->set_do_demangle(getenv("COLLECT_NO_DEMANGLE") == NULL); } + // Parse the --orphan-handling argument. + if (this->user_set_orphan_handling()) + { + if (strcmp(this->orphan_handling(), "place") == 0) + this->set_orphan_handling_enum(ORPHAN_PLACE); + else if (strcmp(this->orphan_handling(), "discard") == 0) + this->set_orphan_handling_enum(ORPHAN_DISCARD); + else if (strcmp(this->orphan_handling(), "warn") == 0) + this->set_orphan_handling_enum(ORPHAN_WARN); + else if (strcmp(this->orphan_handling(), "error") == 0) + this->set_orphan_handling_enum(ORPHAN_ERROR); + } + // -M is equivalent to "-Map -". if (this->print_map() && !this->user_set_Map()) { @@ -1124,6 +1206,13 @@ General_options::finalize() program_name); #endif +#ifndef ENABLE_PLUGINS + if (this->has_plugins()) + gold_fatal(_("cannot use --plugin: " + "%s was compiled without plugin support"), + program_name); +#endif + std::string libpath; if (this->user_set_Y()) { @@ -1201,13 +1290,6 @@ General_options::finalize() // in the path, as appropriate. this->add_sysroot(); - // --dynamic-list overrides -Bsymbolic and -Bsymbolic-functions. - if (this->have_dynamic_list()) - { - this->set_Bsymbolic(false); - this->set_Bsymbolic_functions(false); - } - // Now that we've normalized the options, check for contradictory ones. if (this->shared() && this->is_static()) gold_fatal(_("-shared and -static are incompatible")); @@ -1264,6 +1346,10 @@ General_options::finalize() "--emit-relocs")); if (this->has_plugins()) gold_fatal(_("incremental linking is not compatible with --plugin")); + if (this->relro()) + gold_fatal(_("incremental linking is not compatible with -z relro")); + if (this->pie()) + gold_fatal(_("incremental linking is not compatible with -pie")); if (this->gc_sections()) { gold_warning(_("ignoring --gc-sections for an incremental link")); @@ -1490,6 +1576,12 @@ Command_line::process(int argc, const char** argv) usage(); } + if (this->inputs_.in_lib()) + { + fprintf(stderr, _("%s: missing lib end\n"), program_name); + usage(); + } + // Normalize the options and ensure they don't contradict each other. this->options_.finalize(); }