Fix a segfault when creating an import library with 0 exports.
[binutils-gdb.git] / ld / lexsup.c
index d84b334b346e7d2e49d4482422e1173ecc9ab219..b9cc8a1e957ee70a64101a65c19095a843b0f39a 100644 (file)
@@ -39,9 +39,9 @@
 #include "ldver.h"
 #include "ldemul.h"
 #include "demangle.h"
-#ifdef ENABLE_PLUGINS
+#if BFD_SUPPORTS_PLUGINS
 #include "plugin.h"
-#endif /* ENABLE_PLUGINS */
+#endif /* BFD_SUPPORTS_PLUGINS */
 
 #ifndef PATH_SEPARATOR
 #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__))
@@ -113,6 +113,8 @@ static const struct ld_option ld_options[] =
     'd', NULL, N_("Force common symbols to be defined"), ONE_DASH },
   { {"dp", no_argument, NULL, 'd'},
     '\0', NULL, NULL, ONE_DASH },
+  { {"dependency-file", required_argument, NULL, OPTION_DEPENDENCY_FILE},
+    '\0', N_("FILE"), N_("Write dependency file"), TWO_DASHES },
   { {"force-group-allocation", no_argument, NULL,
      OPTION_FORCE_GROUP_ALLOCATION},
     '\0', NULL, N_("Force group members out of groups"), TWO_DASHES },
@@ -174,7 +176,7 @@ static const struct ld_option ld_options[] =
     'O', NULL, N_("Optimize output file"), ONE_DASH },
   { {"out-implib", required_argument, NULL, OPTION_OUT_IMPLIB},
     '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES },
-#ifdef ENABLE_PLUGINS
+#if BFD_SUPPORTS_PLUGINS
   { {"plugin", required_argument, NULL, OPTION_PLUGIN},
     '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
   { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
@@ -190,7 +192,7 @@ static const struct ld_option ld_options[] =
     '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH },
   { {"plugin-opt", required_argument, NULL, OPTION_IGNORE},
     '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH },
-#endif /* ENABLE_PLUGINS */
+#endif /* BFD_SUPPORTS_PLUGINS */
   { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
     '\0', NULL, N_("Ignored for GCC linker option compatibility"),
     ONE_DASH },
@@ -528,9 +530,9 @@ static const struct ld_option ld_options[] =
   { {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
     '\0', NULL,
 #if DEFAULT_LD_TEXTREL_CHECK_WARNING
-    N_("Warn if outpout has DT_TEXTREL (default)"),
+    N_("Warn if output has DT_TEXTREL (default)"),
 #else
-    N_("Warn if outpout has DT_TEXTREL"),
+    N_("Warn if output has DT_TEXTREL"),
 #endif
     TWO_DASHES },
   { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
@@ -570,6 +572,18 @@ static const struct ld_option ld_options[] =
   { {"no-print-map-discarded", no_argument, NULL, OPTION_NO_PRINT_MAP_DISCARDED},
     '\0', NULL, N_("Do not show discarded sections in map file output"),
     TWO_DASHES },
+  { {"ctf-variables", no_argument, NULL, OPTION_CTF_VARIABLES},
+    '\0', NULL, N_("Emit names and types of static variables in CTF"),
+    TWO_DASHES },
+  { {"no-ctf-variables", no_argument, NULL, OPTION_NO_CTF_VARIABLES},
+    '\0', NULL, N_("Do not emit names and types of static variables in CTF"),
+    TWO_DASHES },
+  { {"ctf-share-types=<method>", required_argument, NULL,
+     OPTION_CTF_SHARE_TYPES},
+    '\0', NULL, N_("How to share CTF types between translation units.\n"
+                  "                                <method> is: share-unconflicted (default),\n"
+                  "                                             share-duplicated"),
+    TWO_DASHES },
 };
 
 #define OPTION_COUNT ARRAY_SIZE (ld_options)
@@ -603,7 +617,7 @@ parse_args (unsigned argc, char **argv)
   longopts = (struct option *)
       xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
   really_longopts = (struct option *)
-      malloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
+      xmalloc (sizeof (*really_longopts) * (OPTION_COUNT + 1));
 
   /* Starting the short option string with '-' is for programs that
      expect options and other ARGV-elements in any order and that care about
@@ -1066,7 +1080,7 @@ parse_args (unsigned argc, char **argv)
        case OPTION_PRINT_OUTPUT_FORMAT:
          command_line.print_output_format = TRUE;
          break;
-#ifdef ENABLE_PLUGINS
+#if BFD_SUPPORTS_PLUGINS
        case OPTION_PLUGIN:
          plugin_opt_plugin (optarg);
          break;
@@ -1074,7 +1088,7 @@ parse_args (unsigned argc, char **argv)
          if (plugin_opt_plugin_arg (optarg))
            einfo (_("%F%P: bad -plugin-opt option\n"));
          break;
-#endif /* ENABLE_PLUGINS */
+#endif /* BFD_SUPPORTS_PLUGINS */
        case 'q':
          link_info.emitrelocations = TRUE;
          break;
@@ -1368,9 +1382,9 @@ parse_args (unsigned argc, char **argv)
              int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0);
              if (*end)
                einfo (_("%F%P: invalid number `%s'\n"), optarg);
-#ifdef ENABLE_PLUGINS
+#if BFD_SUPPORTS_PLUGINS
              report_plugin_symbols = level > 1;
-#endif /* ENABLE_PLUGINS */
+#endif /* BFD_SUPPORTS_PLUGINS */
            }
          break;
        case 'v':
@@ -1441,7 +1455,7 @@ parse_args (unsigned argc, char **argv)
              = lang_new_vers_pattern (NULL, xstrdup (optarg), NULL,
                                       FALSE);
            lang_append_dynamic_list (&export_list, expr);
-          }
+         }
          break;
        case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST:
          /* This option indicates a small script that only specifies
@@ -1631,6 +1645,27 @@ parse_args (unsigned argc, char **argv)
        case OPTION_PRINT_MAP_DISCARDED:
          config.print_map_discarded = TRUE;
          break;
+
+       case OPTION_DEPENDENCY_FILE:
+         config.dependency_file = optarg;
+         break;
+
+       case OPTION_CTF_VARIABLES:
+         config.ctf_variables = TRUE;
+         break;
+
+       case OPTION_NO_CTF_VARIABLES:
+         config.ctf_variables = FALSE;
+         break;
+
+       case OPTION_CTF_SHARE_TYPES:
+         if (strcmp (optarg, "share-unconflicted") == 0)
+           config.ctf_share_duplicated = FALSE;
+         else if (strcmp (optarg, "share-duplicated") == 0)
+           config.ctf_share_duplicated = TRUE;
+         else
+           einfo (_("%F%P: bad --ctf-share-types option: %s\n"), optarg);
+         break;
        }
     }
 
@@ -1913,7 +1948,7 @@ elf_shlib_list_options (FILE *file)
   -z nocombreloc              Don't merge dynamic relocs into one section\n"));
   fprintf (file, _("\
   -z global                   Make symbols in DSO available for subsequently\n\
-                               loaded objects\n"));
+                                loaded objects\n"));
   fprintf (file, _("\
   -z initfirst                Mark DSO to be initialized first at runtime\n"));
   fprintf (file, _("\
@@ -1997,10 +2032,10 @@ elf_static_list_options (FILE *file)
                               Compress DWARF debug sections using zlib\n"));
 #ifdef DEFAULT_FLAG_COMPRESS_DEBUG
   fprintf (file, _("\
-                               Default: zlib-gabi\n"));
+                                Default: zlib-gabi\n"));
 #else
   fprintf (file, _("\
-                               Default: none\n"));
+                                Default: none\n"));
 #endif
   fprintf (file, _("\
   -z common-page-size=SIZE    Set common page size to SIZE\n"));