* dw2gencfi.c (cfi_parse_arg): Only use tc_regname_to_dw2regnum if
[binutils-gdb.git] / ld / lexsup.c
index 8102f4ef12a65a09bc802074a98754cd12e616d7..b2f94f1d367bcc0511014cf2bbd7293d94c164e0 100644 (file)
@@ -467,11 +467,17 @@ parse_args (argc, argv)
   int is, il, irl;
   int ingroup = 0;
   char *default_dirlist = NULL;
-  char shortopts[OPTION_COUNT * 3 + 2];
-  struct option longopts[OPTION_COUNT + 1];
-  struct option really_longopts[OPTION_COUNT + 1];
+  char *shortopts;
+  struct option *longopts;
+  struct option *really_longopts;
   int last_optind;
 
+  shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
+  longopts = (struct option *) xmalloc (sizeof (*longopts)
+                                       * (OPTION_COUNT + 1));
+  really_longopts = (struct option *) 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
      the ordering of the two.  We describe each non-option ARGV-element
@@ -516,6 +522,8 @@ parse_args (argc, argv)
   longopts[il].name = NULL;
   really_longopts[irl].name = NULL;
 
+  ldemul_add_options (is, &shortopts, il, &longopts, irl, &really_longopts);
+
   /* The -G option is ambiguous on different platforms.  Sometimes it
      specifies the largest data size to put into the small data
      section.  Sometimes it is equivalent to --shared.  Unfortunately,
@@ -586,6 +594,9 @@ parse_args (argc, argv)
          optc = getopt_long (argc, argv, "-", really_longopts, &longind);
        }
 
+      if (ldemul_handle_option (optc))
+       continue;
+
       if (optc == -1)
        break;
 
@@ -1036,6 +1047,7 @@ parse_args (argc, argv)
          ldversion (1);
          version_printed = TRUE;
          trace_file_tries = TRUE;
+         overflow_cutoff_limit = -2;
          break;
        case 'v':
          ldversion (0);
@@ -1105,6 +1117,8 @@ parse_args (argc, argv)
        case 'Y':
          if (strncmp (optarg, "P,", 2) == 0)
            optarg += 2;
+         if (default_dirlist != NULL)
+           free (default_dirlist);
          default_dirlist = xstrdup (optarg);
          break;
        case 'y':
@@ -1182,8 +1196,10 @@ parse_args (argc, argv)
     lang_leave_group ();
 
   if (default_dirlist != NULL)
-    set_default_dirlist (default_dirlist);
-
+    {
+      set_default_dirlist (default_dirlist);
+      free (default_dirlist);
+    }
 }
 
 /* Add the (colon-separated) elements of DIRLIST_PTR to the