Add a new option to the linker: --error-handling-script=<NAME>. Run the script ...
[deliverable/binutils-gdb.git] / ld / lexsup.c
index a79bec0b45a8ce9da3340aea60e0f90de7910a4b..eae64932dfcbeaeec4391fc613bfa459eda56bcb 100644 (file)
@@ -386,6 +386,11 @@ static const struct ld_option ld_options[] =
   { {"allow-multiple-definition", no_argument, NULL,
      OPTION_ALLOW_MULTIPLE_DEFINITION},
     '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES },
+#if SUPPORT_ERROR_HANDLING_SCRIPT
+  { {"error-handling-script", required_argument, NULL,
+     OPTION_ERROR_HANDLING_SCRIPT},
+    '\0', N_("SCRIPT"), N_("Provide a script to help with undefined symbol errors"), TWO_DASHES},
+#endif
   { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
     '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
   { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
@@ -572,6 +577,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)
@@ -605,7 +622,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
@@ -723,6 +740,20 @@ parse_args (unsigned argc, char **argv)
          optind = last_optind;
          optc = getopt_long (argc, argv, "-", really_longopts, &longind);
        }
+      /* Attempt to detect grouped short options,  eg: "-non-start".
+        Accepting such options is error prone as it is not clear if the user
+        intended "-n -o n-start" or "--non-start".  */
+      else if (longind == 0  /* This is a short option.  */
+              && optc > 32  /* It is a valid option.  */
+        /* The character is not the second character of argv[last_optind].  */
+              && optc != argv[last_optind][1])
+       {
+         if (optarg)
+           einfo (_("%F%P: Error: unable to disambiguate: %s (did you mean -%s ?)\n"),
+                  argv[last_optind], argv[last_optind]);
+         else
+           einfo (_("%P: Warning: grouped short command line options are deprecated: %s\n"), argv[last_optind]);
+       }
 
       if (ldemul_handle_option (optc))
        continue;
@@ -1017,6 +1048,15 @@ parse_args (unsigned argc, char **argv)
        case OPTION_ALLOW_MULTIPLE_DEFINITION:
          link_info.allow_multiple_definition = TRUE;
          break;
+
+#if SUPPORT_ERROR_HANDLING_SCRIPT
+       case OPTION_ERROR_HANDLING_SCRIPT:
+         /* FIXME: Should we warn if the script is being overridden by another ?
+            Or maybe they should be chained together ?  */
+         error_handling_script = optarg;
+         break;
+#endif
+
        case OPTION_NO_UNDEFINED_VERSION:
          link_info.allow_undefined_version = FALSE;
          break;
@@ -1637,6 +1677,23 @@ parse_args (unsigned argc, char **argv)
        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;
        }
     }
 
@@ -2021,6 +2078,10 @@ elf_static_list_options (FILE *file)
   fprintf (file, _("\
   -z noexecstack              Mark executable as not requiring executable stack\n"));
   fprintf (file, _("\
+  -z unique-symbol            Avoid duplicated local symbol names\n"));
+  fprintf (file, _("\
+  -z nounique-symbol          Keep duplicated local symbol names (default)\n"));
+  fprintf (file, _("\
   -z globalaudit              Mark executable requiring global auditing\n"));
 }
 
This page took 0.024376 seconds and 4 git commands to generate.