* tui/tui-stack.c (tui_make_status_line): Display PC as ?? if unknown.
[deliverable/binutils-gdb.git] / gold / options.cc
index a62c6e1f797b03f92a489503cdcad2ded1dd99d1..f09dccb9367e71b7d1d3b9ae9b8c482be14fd5f5 100644 (file)
@@ -273,6 +273,7 @@ void
 General_options::parse_V(const char*, const char*, Command_line*)
 {
   gold::print_version(true);
+  this->printed_version_ = true;
   printf(_("  Supported targets:\n"));
   std::vector<const char*> supported_names;
   gold::supported_target_names(&supported_names);
@@ -402,27 +403,68 @@ General_options::parse_end_group(const char*, const char*,
   cmdline->inputs().end_group();
 }
 
-} // End namespace gold.
-
-namespace
-{
+// The function add_excluded_libs() in ld/ldlang.c of GNU ld breaks up a list
+// of names seperated by commas or colons and puts them in a linked list.
+// We implement the same parsing of names here but store names in an unordered
+// map to speed up searching of names.
 
 void
-usage()
+General_options::parse_exclude_libs(const char*, const char* arg,
+                                    Command_line*)
 {
-  fprintf(stderr,
-          _("%s: use the --help option for usage information\n"),
-          gold::program_name);
-  ::exit(EXIT_FAILURE);
+  const char *p = arg;
+
+  while (*p != '\0')
+    {
+      size_t length = strcspn(p, ",:");
+      this->excluded_libs_.insert(std::string(p, length));
+      p += (p[length] ? length + 1 : length);
+    }
 }
 
-void
-usage(const char* msg, const char *opt)
+// The checking logic is based on the function check_excluded_libs() in
+// ld/ldlang.c of GNU ld but our implementation is different because we use
+// an unordered map instead of a linked list, which is what GNU ld uses.  GNU
+// ld searches sequentially in the excluded libs list.  For a given archive,
+// a match is found if the archive's name matches exactly one of the list
+// entry or if the archive's name is of the form FOO.a and FOO matches exactly
+// one of the list entry.  An entry "ALL" in the list is considered as a
+// wild-card and matches any given name.
+
+bool
+General_options::check_excluded_libs (const std::string &name) const
 {
-  fprintf(stderr,
-          _("%s: %s: %s\n"),
-          gold::program_name, opt, msg);
-  usage();
+  Unordered_set<std::string>::const_iterator p;
+
+  // Exit early for the most common case.
+  if (excluded_libs_.empty())
+    return false;
+
+  // If we see "ALL", all archives are excluded from automatic export.
+  p = excluded_libs_.find(std::string("ALL"));
+  if (p != excluded_libs_.end())
+    return true;
+
+  // First strip off any directories in name.
+  const char *basename = lbasename(name.c_str());
+
+  // Try finding an exact match.
+  p = excluded_libs_.find(std::string(basename));
+  if (p != excluded_libs_.end())
+    return true;
+
+  // Try matching NAME without ".a" at the end.
+  size_t length = strlen(basename);
+  if ((length >= 2)
+      && (basename[length - 2] == '.')
+      && (basename[length - 1] == 'a'))
+    {
+      p = excluded_libs_.find(std::string(basename, length - 2));
+      if (p != excluded_libs_.end())
+       return true;
+    }
+
+  return false;
 }
 
 // Recognize input and output target names.  The GNU linker accepts
@@ -432,8 +474,8 @@ usage(const char* msg, const char *opt)
 // "elf".  Non-ELF targets would be "srec", "symbolsrec", "tekhex",
 // "binary", "ihex".
 
-gold::General_options::Object_format
-string_to_object_format(const char* arg)
+General_options::Object_format
+General_options::string_to_object_format(const char* arg)
 {
   if (strncmp(arg, "elf", 3) == 0)
     return gold::General_options::OBJECT_FORMAT_ELF;
@@ -448,6 +490,29 @@ string_to_object_format(const char* arg)
     }
 }
 
+} // End namespace gold.
+
+namespace
+{
+
+void
+usage()
+{
+  fprintf(stderr,
+          _("%s: use the --help option for usage information\n"),
+          gold::program_name);
+  ::exit(EXIT_FAILURE);
+}
+
+void
+usage(const char* msg, const char *opt)
+{
+  fprintf(stderr,
+          _("%s: %s: %s\n"),
+          gold::program_name, opt, msg);
+  usage();
+}
+
 // If the default sysroot is relocatable, try relocating it based on
 // the prefix FROM.
 
@@ -644,7 +709,8 @@ namespace gold
 {
 
 General_options::General_options()
-  : execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false),
+  : printed_version_(false),
+    execstack_status_(General_options::EXECSTACK_FROM_INPUT), static_(false),
     do_demangle_(false), plugins_(),
     incremental_disposition_(INCREMENTAL_CHECK), implicit_incremental_(false)
 {
@@ -653,13 +719,13 @@ General_options::General_options()
 General_options::Object_format
 General_options::format_enum() const
 {
-  return string_to_object_format(this->format());
+  return General_options::string_to_object_format(this->format());
 }
 
 General_options::Object_format
 General_options::oformat_enum() const
 {
-  return string_to_object_format(this->oformat());
+  return General_options::string_to_object_format(this->oformat());
 }
 
 // Add the sysroot, if any, to the search paths.
This page took 0.024859 seconds and 4 git commands to generate.