PR 9766
[deliverable/binutils-gdb.git] / gold / options.h
index 419e70bb4e1100cc743867c62373f0bf7e8af56b..ba61d17289a52ffdb5deeff4459c4dc587e544bf 100644 (file)
@@ -54,6 +54,7 @@ class Search_directory;
 class Input_file_group;
 class Position_dependent_options;
 class Target;
+class Plugin_manager;
 
 // 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
@@ -239,6 +240,10 @@ struct Struct_special : public Struct_var
   user_set_##varname__() const                                               \
   { return this->varname__##_.user_set_via_option; }                         \
                                                                              \
+  void                                                                      \
+  set_user_set_##varname__()                                                \
+  { this->varname__##_.user_set_via_option = true; }                        \
+                                                                            \
  private:                                                                    \
   struct Struct_##varname__ : public options::Struct_var                     \
   {                                                                          \
@@ -268,7 +273,8 @@ struct Struct_special : public Struct_var
 // These macros allow for easy addition of a new commandline option.
 
 // If no_helpstring__ is not NULL, then in addition to creating
-// VARNAME, we also create an option called no-VARNAME.
+// VARNAME, we also create an option called no-VARNAME (or, for a -z
+// option, noVARNAME).
 #define DEFINE_bool(varname__, dashes__, shortname__, default_value__,   \
                     helpstring__, no_helpstring__)                       \
   DEFINE_var(varname__, dashes__, shortname__, default_value__,          \
@@ -276,7 +282,10 @@ struct Struct_special : public Struct_var
              false, bool, bool, options::parse_bool)                    \
   struct Struct_no_##varname__ : public options::Struct_var              \
   {                                                                      \
-    Struct_no_##varname__() : option("no-" #varname__, dashes__, '\0',   \
+    Struct_no_##varname__() : option((dashes__ == options::DASH_Z       \
+                                     ? "no" #varname__                  \
+                                     : "no-" #varname__),               \
+                                    dashes__, '\0',                     \
                                      default_value__ ? "false" : "true", \
                                      no_helpstring__, NULL, false, this) \
     { }                                                                  \
@@ -361,13 +370,22 @@ struct Struct_special : public Struct_var
   bool                                                                    \
   any_##varname__() const                                                 \
   { return !this->varname__##_.value.empty(); }                           \
+                                                                         \
   bool                                                                    \
   is_##varname__(const char* symbol) const                                \
   {                                                                       \
     return (!this->varname__##_.value.empty()                             \
             && (this->varname__##_.value.find(std::string(symbol))        \
                 != this->varname__##_.value.end()));                      \
-  }
+  }                                                                      \
+                                                                         \
+  options::String_set::const_iterator                                    \
+  varname__##_begin() const                                              \
+  { return this->varname__##_.value.begin(); }                           \
+                                                                         \
+  options::String_set::const_iterator                                    \
+  varname__##_end() const                                                \
+  { return this->varname__##_.value.end(); }
 
 // When you have a list of possible values (expressed as string)
 // After helparg__ should come an initializer list, like
@@ -386,6 +404,53 @@ struct Struct_special : public Struct_var
                            choices, sizeof(choices) / sizeof(*choices)); \
   }
 
+// This is like DEFINE_bool, but VARNAME is the name of a different
+// option.  This option becomes an alias for that one.  INVERT is true
+// if this option is an inversion of the other one.
+#define DEFINE_bool_alias(option__, varname__, dashes__, shortname__,  \
+                         helpstring__, no_helpstring__, invert__)      \
+ private:                                                              \
+  struct Struct_##option__ : public options::Struct_var                        \
+  {                                                                    \
+    Struct_##option__()                                                        \
+      : option(#option__, dashes__, shortname__, "", helpstring__,     \
+              NULL, false, this)                                       \
+    { }                                                                        \
+                                                                       \
+    void                                                               \
+    parse_to_value(const char*, const char*,                           \
+                  Command_line*, General_options* options)             \
+    {                                                                  \
+      options->set_##varname__(!invert__);                             \
+      options->set_user_set_##varname__();                             \
+    }                                                                  \
+                                                                       \
+    options::One_option option;                                                \
+  };                                                                   \
+  Struct_##option__ option__##_;                                       \
+                                                                       \
+  struct Struct_no_##option__ : public options::Struct_var             \
+  {                                                                    \
+    Struct_no_##option__()                                             \
+      : option((dashes__ == options::DASH_Z                            \
+               ? "no" #option__                                        \
+               : "no-" #option__),                                     \
+              dashes__, '\0', "", no_helpstring__,                     \
+              NULL, false, this)                                       \
+    { }                                                                        \
+                                                                       \
+    void                                                               \
+    parse_to_value(const char*, const char*,                           \
+                  Command_line*, General_options* options)             \
+    {                                                                  \
+      options->set_##varname__(invert__);                              \
+      options->set_user_set_##varname__();                             \
+    }                                                                  \
+                                                                       \
+    options::One_option option;                                                \
+  };                                                                   \
+  Struct_no_##option__ no_##option__##_initializer_
+
 // This is used for non-standard flags.  It defines no functions; it
 // just calls General_options::parse_VARNAME whenever the flag is
 // seen.  We declare parse_VARNAME as a static member of
@@ -498,18 +563,28 @@ class General_options
 
   DEFINE_bool(Bdynamic, options::ONE_DASH, '\0', true,
               N_("-l searches for shared libraries"), NULL);
-  // Bstatic affects the same variable as Bdynamic, so we have to use
-  // the "special" macro to make that happen.
-  DEFINE_special(Bstatic, options::ONE_DASH, '\0',
-                 N_("-l does not search for shared libraries"), NULL);
+  DEFINE_bool_alias(Bstatic, Bdynamic, options::ONE_DASH, '\0',
+                   N_("-l does not search for shared libraries"), NULL,
+                   true);
 
   DEFINE_bool(Bsymbolic, options::ONE_DASH, '\0', false,
               N_("Bind defined symbols locally"), NULL);
 
+  DEFINE_bool(Bsymbolic_functions, options::ONE_DASH, '\0', false,
+             N_("Bind defined function symbols locally"), NULL);
+
   DEFINE_optional_string(build_id, options::TWO_DASHES, '\0', "sha1",
                         N_("Generate build ID note"),
                         N_("[=STYLE]"));
 
+  DEFINE_bool(check_sections, options::TWO_DASHES, '\0', true,
+             N_("Check segment addresses for overlaps (default)"),
+             N_("Do not check segment addresses for overlaps"));
+
+  DEFINE_bool(gc_sections, options::TWO_DASHES, '\0', true,
+             N_("(noop) Garbage collect sections"),
+             N_("(noop) Do not garbage collect sections"));
+
 #ifdef HAVE_ZLIB_H
   DEFINE_enum(compress_debug_sections, options::TWO_DASHES, '\0', "none",
               N_("Compress .debug_* sections in the output file"),
@@ -549,15 +624,32 @@ class General_options
               N_("Try to detect violations of the One Definition Rule"),
               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_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);
 
+  DEFINE_bool(fatal_warnings, options::TWO_DASHES, '\0', false,
+             N_("Treat warnings as errors"),
+             N_("Do not treat warnings as errors"));
+
   DEFINE_string(soname, options::ONE_DASH, 'h', NULL,
                 N_("Set shared library name"), N_("FILENAME"));
 
@@ -584,6 +676,17 @@ class General_options
   DEFINE_string(m, options::EXACTLY_ONE_DASH, 'm', "",
                 N_("Ignored for compatibility"), N_("EMULATION"));
 
+  DEFINE_bool(print_map, options::TWO_DASHES, 'M', false,
+             N_("Write map file on standard output"), NULL);
+  DEFINE_string(Map, options::ONE_DASH, '\0', NULL, N_("Write map file"),
+               N_("MAPFILENAME"));
+
+  DEFINE_bool(nmagic, options::TWO_DASHES, 'n', false,
+             N_("Do not page align data"), NULL);
+  DEFINE_bool(omagic, options::EXACTLY_TWO_DASHES, 'N', false,
+             N_("Do not page align data, do not make text readonly"),
+             N_("Page align data, make text readonly"));
+
   DEFINE_enable(new_dtags, options::EXACTLY_TWO_DASHES, '\0', false,
                N_("Enable use of DT_RUNPATH and DT_FLAGS"),
                N_("Disable use of DT_RUNPATH and DT_FLAGS"));
@@ -591,6 +694,10 @@ class General_options
   DEFINE_bool(noinhibit_exec, options::TWO_DASHES, '\0', false,
              N_("Create an output file even if errors occur"), NULL);
 
+  DEFINE_bool_alias(no_undefined, defs, options::TWO_DASHES, '\0',
+                   N_("Report undefined symbols (even with --shared)"),
+                   NULL, false);
+
   DEFINE_string(output, options::TWO_DASHES, 'o', "a.out",
                 N_("Set output file name"), N_("FILE"));
 
@@ -600,6 +707,20 @@ class General_options
   DEFINE_string(oformat, options::EXACTLY_TWO_DASHES, '\0', "elf",
                N_("Set output format"), N_("[binary]"));
 
+#ifdef ENABLE_PLUGINS
+  DEFINE_special(plugin, options::TWO_DASHES, '\0',
+                 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,
+              N_("Preread archive symbols when multi-threaded"), NULL);
+
+  DEFINE_string(print_symbol_counts, options::TWO_DASHES, '\0', NULL,
+               N_("Print symbols defined and used for each input"),
+               N_("FILENAME"));
+
   DEFINE_bool(Qy, options::EXACTLY_ONE_DASH, '\0', false,
              N_("Ignored for SVR4 compatibility"), NULL);
 
@@ -629,13 +750,23 @@ class General_options
               N_("Strip all symbols"), NULL);
   DEFINE_bool(strip_debug, options::TWO_DASHES, 'S', false,
               N_("Strip debugging information"), NULL);
+  DEFINE_bool(strip_debug_non_line, options::TWO_DASHES, '\0', false,
+              N_("Emit only debug line number information"), NULL);
   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, 's', 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',
@@ -672,6 +803,9 @@ class General_options
   DEFINE_uint64(Ttext, options::ONE_DASH, '\0', -1U,
                 N_("Set the address of the text segment"), N_("ADDRESS"));
 
+  DEFINE_set(undefined, options::TWO_DASHES, 'u',
+            N_("Create undefined reference to SYMBOL"), N_("SYMBOL"));
+
   DEFINE_bool(verbose, options::TWO_DASHES, '\0', false,
               N_("Synonym for --debug=files"), NULL);
 
@@ -699,8 +833,9 @@ class General_options
 
   // The -z options.
 
-  // Both execstack and noexecstack differ from the default execstack_
-  // value, so we need to use different variables for them.
+  DEFINE_bool(combreloc, options::DASH_Z, '\0', true,
+             N_("Sort dynamic relocs"),
+             N_("Do not sort dynamic relocs"));
   DEFINE_uint64(common_page_size, options::DASH_Z, '\0', 0,
                 N_("Set common page size to SIZE"), N_("SIZE"));
   DEFINE_bool(defs, options::DASH_Z, '\0', false,
@@ -733,6 +868,12 @@ 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(origin, options::DASH_Z, '\0', false,
+             N_("Mark DSO to indicate that needs immediate $ORIGIN "
+                 "processing at runtime"), NULL);
 
  public:
   typedef options::Dir_list Dir_list;
@@ -758,6 +899,20 @@ class General_options
   output_is_position_independent() const
   { return this->shared(); }
 
+  // Return true if the output is something that can be exec()ed, such
+  // as a static executable, or a position-dependent or
+  // position-independent executable, but not a dynamic library or an
+  // object file.
+  bool
+  output_is_executable() const
+  { return !this->shared() || this->output_is_pie(); }
+
+  // Return true if the output is a position-independent executable.
+  // This is currently not supported.
+  bool
+  output_is_pie() const
+  { return false; }
+
   // This would normally be static(), and defined automatically, but
   // since static is a keyword, we need to come up with our own name.
   bool
@@ -795,6 +950,21 @@ class General_options
   do_demangle() const
   { return this->do_demangle_; }
 
+  // Returns TRUE if any plugin libraries have been loaded.
+  bool
+  has_plugins() const
+  { return this->plugins_ != NULL; }
+
+  // Return a pointer to the plugin manager.
+  Plugin_manager*
+  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); }
+
  private:
   // Don't copy this structure.
   General_options(const General_options&);
@@ -832,12 +1002,26 @@ class General_options
   void
   add_sysroot();
 
+  // Add a plugin and its arguments to the list of plugins.
+  void
+  add_plugin(const char *filename);
+
+  // Add a plugin option.
+  void
+  add_plugin_option(const char* opt);
+
   // Whether to mark the stack as executable.
   Execstack execstack_status_;
   // Whether to do a static link.
   bool static_;
   // Whether to do demangling.
   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 position-dependent options.  We use this to store the state of
This page took 0.050138 seconds and 4 git commands to generate.