* object.cc (Sized_relobj::do_count): Test should_retain_symbol map.
[deliverable/binutils-gdb.git] / gold / options.h
index 167e58a09ea932fea2298ef645432b0f84140e78..258d62813983418850339fe0314b1733f36bcec7 100644 (file)
@@ -1,6 +1,6 @@
 // options.h -- handle command line options for gold  -*- C++ -*-
 
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -56,6 +56,18 @@ class Position_dependent_options;
 class Target;
 class Plugin_manager;
 
+// Incremental build action for a specific file, as selected by the user.
+
+enum Incremental_disposition
+{
+  // Determine the status from the timestamp (default).
+  INCREMENTAL_CHECK,
+  // Assume the file changed from the previous build.
+  INCREMENTAL_CHANGED,
+  // Assume the file didn't change from the previous build.
+  INCREMENTAL_UNCHANGED
+};
+
 // The nested namespace is to contain all the global variables and
 // structs that need to be defined in the .h file, but do not need to
 // be used outside this class.
@@ -522,9 +534,22 @@ class Search_directory
   is_in_sysroot() const
   { return this->is_in_sysroot_; }
 
+  // Return whether this is considered a system directory.
+  bool
+  is_system_directory() const
+  { return this->put_in_sysroot_ || this->is_in_sysroot_; }
+
  private:
+  // The directory name.
   std::string name_;
+  // True if the sysroot should be added as a prefix for this
+  // directory (if there is a sysroot).  This is true for system
+  // directories that we search by default.
   bool put_in_sysroot_;
+  // True if this directory is in the sysroot (if there is a sysroot).
+  // This is true if there is a sysroot and either 1) put_in_sysroot_
+  // is true, or 2) the directory happens to be in the sysroot based
+  // on a pathname comparison.
   bool is_in_sysroot_;
 };
 
@@ -620,11 +645,31 @@ class General_options
               N_("Try to detect violations of the One Definition Rule"),
               NULL);
 
+  DEFINE_bool(discard_locals, options::TWO_DASHES, 'X', false,
+              N_("Delete all temporary local symbols"), NULL);
+
+  DEFINE_bool(dynamic_list_data, options::TWO_DASHES, '\0', false,
+              N_("Add data symbols to dynamic symbols"), NULL);
+
+  DEFINE_bool(dynamic_list_cpp_new, options::TWO_DASHES, '\0', false,
+              N_("Add C++ operator new/delete to dynamic symbols"), NULL);
+
+  DEFINE_bool(dynamic_list_cpp_typeinfo, options::TWO_DASHES, '\0', false,
+              N_("Add C++ typeinfo to dynamic symbols"), NULL);
+
+  DEFINE_special(dynamic_list, options::TWO_DASHES, '\0',
+                 N_("Read a list of dynamic symbols"), N_("FILE"));
+
   DEFINE_string(entry, options::TWO_DASHES, 'e', NULL,
                 N_("Set program start address"), N_("ADDRESS"));
 
+  DEFINE_special(exclude_libs, options::TWO_DASHES, '\0',
+                N_("Exclude libraries from automatic export"),
+                N_(("lib,lib ...")));
+
   DEFINE_bool(export_dynamic, options::TWO_DASHES, 'E', false,
-              N_("Export all dynamic symbols"), NULL);
+              N_("Export all dynamic symbols"),
+             N_("Do not export all dynamic symbols (default)"));
 
   DEFINE_bool(eh_frame_hdr, options::TWO_DASHES, '\0', false,
               N_("Create exception frame header"), NULL);
@@ -647,6 +692,19 @@ class General_options
   DEFINE_string(dynamic_linker, options::TWO_DASHES, 'I', NULL,
                 N_("Set dynamic linker path"), N_("PROGRAM"));
 
+  DEFINE_bool(incremental, options::TWO_DASHES, '\0', false,
+              N_("Work in progress; do not use"),
+              N_("Do a full build"));
+
+  DEFINE_special(incremental_changed, options::TWO_DASHES, '\0',
+                 N_("Assume files changed"), NULL);
+
+  DEFINE_special(incremental_unchanged, options::TWO_DASHES, '\0',
+                 N_("Assume files didn't change"), NULL);
+
+  DEFINE_special(incremental_unknown, options::TWO_DASHES, '\0',
+                 N_("Use timestamps to check files (default)"), NULL);
+
   DEFINE_special(just_symbols, options::TWO_DASHES, '\0',
                  N_("Read only symbol values from FILE"), N_("FILE"));
 
@@ -692,7 +750,9 @@ class General_options
 
 #ifdef ENABLE_PLUGINS
   DEFINE_special(plugin, options::TWO_DASHES, '\0',
-                 N_("Load a plugin library"), N_("PLUGIN[,ARG,...]"));
+                 N_("Load a plugin library"), N_("PLUGIN"));
+  DEFINE_special(plugin_opt, options::TWO_DASHES, '\0',
+                 N_("Pass an option to the plugin"), N_("OPTION"));
 #endif
 
   DEFINE_bool(preread_archive_symbols, options::TWO_DASHES, '\0', false,
@@ -714,6 +774,9 @@ class General_options
   DEFINE_bool(relax, options::TWO_DASHES, '\0', false,
              N_("Relax branches on certain targets"), NULL);
 
+  DEFINE_string(retain_symbols_file, options::EXACTLY_ONE_DASH, '\0', NULL,
+                N_("keep only symbols listed in this file"), N_("[file]"));
+
   // -R really means -rpath, but can mean --just-symbols for
   // compatibility with GNU ld.  -rpath is always -rpath, so we list
   // it separately.
@@ -736,15 +799,46 @@ class General_options
   DEFINE_bool(strip_debug_gdb, options::TWO_DASHES, '\0', false,
               N_("Strip debug symbols that are unused by gdb "
                  "(at least versions <= 6.7)"), NULL);
+  DEFINE_bool(strip_lto_sections, options::TWO_DASHES, '\0', true,
+              N_("Strip LTO intermediate code sections"), NULL);
+
+  DEFINE_bool(no_keep_memory, options::TWO_DASHES, '\0', false,
+              N_("Use less memory and more disk I/O "
+                 "(included only for compatibility with GNU ld)"), NULL);
 
   DEFINE_bool(shared, options::ONE_DASH, '\0', false,
               N_("Generate shared library"), NULL);
 
+  DEFINE_bool(Bshareable, options::ONE_DASH, '\0', false,
+              N_("Generate shared library"), NULL);
+
   // This is not actually special in any way, but I need to give it
   // a non-standard accessor-function name because 'static' is a keyword.
   DEFINE_special(static, options::ONE_DASH, '\0',
                  N_("Do not link against shared libraries"), NULL);
 
+  DEFINE_bool(icf, options::TWO_DASHES, '\0', false,
+              N_("Identical Code Folding (Fold identical functions)"),
+              N_("Don't fold identical functions (default)"));
+
+  DEFINE_uint(icf_iterations, options::TWO_DASHES , '\0', 0,
+              N_("Number of iterations of ICF (default 2)"), N_("COUNT"));
+
+  DEFINE_bool(print_icf_sections, options::TWO_DASHES, '\0', false,
+              N_("List folded identical sections on stderr"),
+              N_("Do not list folded identical sections"));
+
+  DEFINE_set(keep_unique, options::TWO_DASHES, '\0',
+            N_("Do not fold this symbol during ICF"), N_("SYMBOL"));
+
+  DEFINE_bool(gc_sections, options::TWO_DASHES, '\0', false,
+              N_("Remove unused sections"),
+              N_("Don't remove unused sections (default)"));
+
+  DEFINE_bool(print_gc_sections, options::TWO_DASHES, '\0', false,
+              N_("List removed unused sections on stderr"),
+              N_("Do not list removed unused sections"));
+
   DEFINE_bool(stats, options::TWO_DASHES, '\0', false,
               N_("Print resource usage statistics"), NULL);
 
@@ -785,6 +879,10 @@ class General_options
   DEFINE_special(version_script, options::TWO_DASHES, '\0',
                  N_("Read version script"), N_("FILE"));
 
+  DEFINE_bool(warn_search_mismatch, options::TWO_DASHES, '\0', true,
+             N_("Warn when skipping an incompatible library"),
+             N_("Don't warn when skipping an incompatible library"));
+
   DEFINE_bool(whole_archive, options::TWO_DASHES, '\0', false,
               N_("Include all archive contents"),
               N_("Include only needed archive contents"));
@@ -816,19 +914,20 @@ class General_options
               NULL);
   DEFINE_bool(execstack, options::DASH_Z, '\0', false,
               N_("Mark output as requiring executable stack"), NULL);
-  DEFINE_uint64(max_page_size, options::DASH_Z, '\0', 0,
-                N_("Set maximum page size to SIZE"), N_("SIZE"));
-  DEFINE_bool(noexecstack, options::DASH_Z, '\0', false,
-              N_("Mark output as not requiring executable stack"), NULL);
   DEFINE_bool(initfirst, options::DASH_Z, '\0', false,
              N_("Mark DSO to be initialized first at runtime"),
              NULL);
   DEFINE_bool(interpose, options::DASH_Z, '\0', false,
              N_("Mark object to interpose all DSOs but executable"),
              NULL);
+  DEFINE_bool(lazy, options::DASH_Z, '\0', false,
+             N_("Mark object for lazy runtime binding (default)"),
+             NULL);
   DEFINE_bool(loadfltr, options::DASH_Z, '\0', false,
              N_("Mark object requiring immediate process"),
              NULL);
+  DEFINE_uint64(max_page_size, options::DASH_Z, '\0', 0,
+                N_("Set maximum page size to SIZE"), N_("SIZE"));
   DEFINE_bool(nodefaultlib, options::DASH_Z, '\0', false,
              N_("Mark object not to use default search paths"),
              NULL);
@@ -841,12 +940,17 @@ class General_options
   DEFINE_bool(nodump, options::DASH_Z, '\0', false,
              N_("Mark DSO not available to dldump"),
              NULL);
-  DEFINE_bool(relro, options::DASH_Z, '\0', false,
-             N_("Where possible mark variables read-only after relocation"),
-             N_("Don't mark variables read-only after relocation"));
+  DEFINE_bool(noexecstack, options::DASH_Z, '\0', false,
+              N_("Mark output as not requiring executable stack"), NULL);
+  DEFINE_bool(now, options::DASH_Z, '\0', false,
+             N_("Mark object for immediate function binding"),
+             NULL);
   DEFINE_bool(origin, options::DASH_Z, '\0', false,
              N_("Mark DSO to indicate that needs immediate $ORIGIN "
                  "processing at runtime"), NULL);
+  DEFINE_bool(relro, options::DASH_Z, '\0', false,
+             N_("Where possible mark variables read-only after relocation"),
+             N_("Don't mark variables read-only after relocation"));
 
  public:
   typedef options::Dir_list Dir_list;
@@ -860,6 +964,11 @@ class General_options
   // any problems.
   void finalize();
 
+  // True if we printed the version information.
+  bool
+  printed_version() const
+  { return this->printed_version_; }
+
   // The macro defines output() (based on --output), but that's a
   // generic name.  Provide this alternative name, which is clearer.
   const char*
@@ -902,10 +1011,28 @@ class General_options
     OBJECT_FORMAT_BINARY
   };
 
+  // Convert a string to an Object_format.  Gives an error if the
+  // string is not recognized.
+  static Object_format
+  string_to_object_format(const char* arg);
+
   // Note: these functions are not very fast.
   Object_format format_enum() const;
   Object_format oformat_enum() const;
 
+  // Return whether FILENAME is in a system directory.
+  bool
+  is_in_system_directory(const std::string& name) const;
+
+  // RETURN whether SYMBOL_NAME should be kept, according to symbols_to_retain_.
+  bool
+  should_retain_symbol(const char* symbol_name) const
+    {
+      if (symbols_to_retain_.empty())    // means flag wasn't specified
+        return true;
+      return symbols_to_retain_.find(symbol_name) != symbols_to_retain_.end();
+    }
+
   // These are the best way to get access to the execstack state,
   // not execstack() and noexecstack() which are hard to use properly.
   bool
@@ -933,6 +1060,23 @@ class General_options
   plugins() const
   { return this->plugins_; }
 
+  // True iff SYMBOL was found in the file specified by dynamic-list.
+  bool
+  in_dynamic_list(const char* symbol) const
+  { return this->dynamic_list_.version_script_info()->symbol_is_local(symbol); }
+
+  // The disposition given by the --incremental-changed,
+  // --incremental-unchanged or --incremental-unknown option.  The
+  // value may change as we proceed parsing the command line flags.
+  Incremental_disposition
+  incremental_disposition() const
+  { return this->incremental_disposition_; }
+
+  // Return true if S is the name of a library excluded from automatic
+  // symbol export.
+  bool
+  check_excluded_libs (const std::string &s) const;
+
  private:
   // Don't copy this structure.
   General_options(const General_options&);
@@ -972,8 +1116,14 @@ class General_options
 
   // Add a plugin and its arguments to the list of plugins.
   void
-  add_plugin(const char* arg);
+  add_plugin(const char *filename);
+
+  // Add a plugin option.
+  void
+  add_plugin_option(const char* opt);
 
+  // Whether we printed version information.
+  bool printed_version_;
   // Whether to mark the stack as executable.
   Execstack execstack_status_;
   // Whether to do a static link.
@@ -982,6 +1132,22 @@ class General_options
   bool do_demangle_;
   // List of plugin libraries.
   Plugin_manager* plugins_;
+  // The parsed output of --dynamic-list files.  For convenience in
+  // script.cc, we store this as a Script_options object, even though
+  // we only use a single Version_tree from it.
+  Script_options dynamic_list_;
+  // The disposition given by the --incremental-changed,
+  // --incremental-unchanged or --incremental-unknown option.  The
+  // value may change as we proceed parsing the command line flags.
+  Incremental_disposition incremental_disposition_;
+  // Whether we have seen one of the options that require incremental
+  // build (--incremental-changed, --incremental-unchanged or
+  // --incremental-unknown)
+  bool implicit_incremental_;
+  // Libraries excluded from automatic export, via --exclude-libs.
+  Unordered_set<std::string> excluded_libs_;
+  // List of symbol-names to keep, via -retain-symbol-info.
+  Unordered_set<std::string> symbols_to_retain_;
 };
 
 // The position-dependent options.  We use this to store the state of
@@ -1018,12 +1184,14 @@ class Position_dependent_options
     this->set_Bdynamic(options.Bdynamic());
     this->set_format_enum(options.format_enum());
     this->set_whole_archive(options.whole_archive());
+    this->set_incremental_disposition(options.incremental_disposition());
   }
 
   DEFINE_posdep(as_needed, bool);
   DEFINE_posdep(Bdynamic, bool);
   DEFINE_posdep(format_enum, General_options::Object_format);
   DEFINE_posdep(whole_archive, bool);
+  DEFINE_posdep(incremental_disposition, Incremental_disposition);
 
  private:
   // This is a General_options with everything set to its default
@@ -1168,14 +1336,15 @@ class Input_argument
   Input_file_group* group_;
 };
 
+typedef std::vector<Input_argument> Input_argument_list;
+
 // A group from the command line.  This is a set of arguments within
 // --start-group ... --end-group.
 
 class Input_file_group
 {
  public:
-  typedef std::vector<Input_argument> Files;
-  typedef Files::const_iterator const_iterator;
+  typedef Input_argument_list::const_iterator const_iterator;
 
   Input_file_group()
     : files_()
@@ -1197,7 +1366,7 @@ class Input_file_group
   { return this->files_.end(); }
 
  private:
-  Files files_;
+  Input_argument_list files_;
 };
 
 // A list of files from the command line or a script.
@@ -1205,7 +1374,6 @@ class Input_file_group
 class Input_arguments
 {
  public:
-  typedef std::vector<Input_argument> Input_argument_list;
   typedef Input_argument_list::const_iterator const_iterator;
 
   Input_arguments()
@@ -1325,6 +1493,16 @@ class Command_line
   Command_line(const Command_line&);
   Command_line& operator=(const Command_line&);
 
+  // This is a dummy class to provide a constructor that runs before
+  // the constructor for the General_options.  The Pre_options constructor
+  // is used as a hook to set the flag enabling the options to register
+  // themselves.
+  struct Pre_options {
+    Pre_options();
+  };
+
+  // This must come before options_!
+  Pre_options pre_options_;
   General_options options_;
   Position_dependent_options position_options_;
   Script_options script_options_;
This page took 0.027363 seconds and 4 git commands to generate.