spacing fix
[binutils-gdb.git] / ld / lexsup.c
index e82fda0f275c657e2e7166dc2b70d59fc76895c6..bf61c74793355114c74d0213f4b80966f1005ac8 100644 (file)
@@ -19,6 +19,7 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307
 
 #include "bfd.h"
 #include "sysdep.h"
+#include "libiberty.h"
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -56,7 +57,8 @@ int parsing_defsym = 0;
 
 #define OPTION_ASSERT                  150
 #define OPTION_CALL_SHARED             (OPTION_ASSERT + 1)
-#define OPTION_DEFSYM                  (OPTION_CALL_SHARED + 1)
+#define OPTION_CREF                    (OPTION_CALL_SHARED + 1)
+#define OPTION_DEFSYM                  (OPTION_CREF + 1)
 #define OPTION_DYNAMIC_LINKER          (OPTION_DEFSYM + 1)
 #define OPTION_EB                      (OPTION_DYNAMIC_LINKER + 1)
 #define OPTION_EL                      (OPTION_EB + 1)
@@ -94,6 +96,7 @@ int parsing_defsym = 0;
 #define OPTION_SPLIT_BY_FILE           (OPTION_SPLIT_BY_RELOC + 1)
 #define OPTION_WHOLE_ARCHIVE           (OPTION_SPLIT_BY_FILE + 1)
 #define OPTION_WRAP                    (OPTION_WHOLE_ARCHIVE + 1)
+#define OPTION_FORCE_EXE_SUFFIX                (OPTION_WRAP + 1)
 
 /* The long options.  This structure is used for both the option
    parsing and the help text.  */
@@ -139,13 +142,13 @@ static const struct ld_option ld_options[] =
       'e', "ADDRESS", "Set start address", TWO_DASHES },
   { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
       'E', NULL, "Export all dynamic symbols", TWO_DASHES },
+  { {NULL, optional_argument, NULL, '\0'},
+      'F', "[FORMAT]", "Ignored", ONE_DASH },
   { {NULL, no_argument, NULL, '\0'},
-      'F', NULL, "Ignored", ONE_DASH },
+      'g', NULL, "Ignored", ONE_DASH },
   { {"gpsize", required_argument, NULL, 'G'},
       'G', "SIZE", "Small data size (if no size, same as --shared)",
       TWO_DASHES },
-  { {NULL, no_argument, NULL, '\0'},
-      'g', NULL, "Ignored", ONE_DASH },
   { {"soname", required_argument, NULL, OPTION_SONAME},
       'h', "FILENAME", "Set internal name of shared library", ONE_DASH },
   { {"library", required_argument, NULL, 'l'},
@@ -204,10 +207,10 @@ static const struct ld_option ld_options[] =
       '\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH },
   { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
       '\0', NULL, "Link against shared libraries", ONE_DASH },
-  { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
-      '\0', NULL, NULL, ONE_DASH },
   { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
       '\0', NULL, NULL, ONE_DASH },
+  { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
+      '\0', NULL, NULL, ONE_DASH },
   { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
       '\0', NULL, "Do not link against shared libraries", ONE_DASH },
   { {"dn", no_argument, NULL, OPTION_NON_SHARED},
@@ -218,6 +221,8 @@ static const struct ld_option ld_options[] =
       '\0', NULL, NULL, ONE_DASH },
   { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
       '\0', NULL, "Bind global references locally", ONE_DASH },
+  { {"cref", no_argument, NULL, OPTION_CREF},
+      '\0', NULL, "Output cross reference table", TWO_DASHES },
   { {"defsym", required_argument, NULL, OPTION_DEFSYM},
       '\0', "SYMBOL=EXPRESSION", "Define a symbol", TWO_DASHES },
   { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
@@ -228,6 +233,8 @@ static const struct ld_option ld_options[] =
       '\0', NULL, "Link little-endian objects", ONE_DASH },
   { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
       '\0', NULL, "Generate embedded relocs", TWO_DASHES},
+  { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
+      '\0', NULL, "Force generation of file with .exe suffix", TWO_DASHES},
   { {"help", no_argument, NULL, OPTION_HELP},
       '\0', NULL, "Print option help", TWO_DASHES },
   { {"Map", required_argument, NULL, OPTION_MAP},
@@ -254,7 +261,7 @@ static const struct ld_option ld_options[] =
   { {"rpath", required_argument, NULL, OPTION_RPATH},
       '\0', "PATH", "Set runtime shared library search path", ONE_DASH },
   { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
-      '\0', "PATH", "Set line time shared library search path", ONE_DASH },
+      '\0', "PATH", "Set link time shared library search path", ONE_DASH },
   { {"shared", no_argument, NULL, OPTION_SHARED},
       '\0', NULL, "Create a shared library", ONE_DASH },
   { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD.  */
@@ -281,7 +288,7 @@ static const struct ld_option ld_options[] =
       '\0', NULL, "Build global constructor/destructor tables", ONE_DASH },
   { {"verbose", no_argument, NULL, OPTION_VERBOSE},
       '\0', NULL, "Output lots of information during link", TWO_DASHES },
-  { {"dll-verbose", no_argument, NULL, OPTION_VERSION}, /* Linux.  */
+  { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux.  */
       '\0', NULL, NULL, NO_HELP },
   { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
       '\0', NULL, "Warn about duplicate common symbols", TWO_DASHES },
@@ -308,7 +315,7 @@ parse_args (argc, argv)
   int i, is, il;
   int ingroup = 0;
   char *default_dirlist = NULL;
-  char shortopts[OPTION_COUNT * 2 + 2];
+  char shortopts[OPTION_COUNT * 3 + 2];
   struct option longopts[OPTION_COUNT + 1];
 
   /* Starting the short option string with '-' is for programs that
@@ -324,10 +331,16 @@ parse_args (argc, argv)
        {
          shortopts[is] = ld_options[i].shortopt;
          ++is;
-         if (ld_options[i].opt.has_arg == required_argument)
+         if (ld_options[i].opt.has_arg == required_argument
+             || ld_options[i].opt.has_arg == optional_argument)
            {
              shortopts[is] = ':';
              ++is;
+             if (ld_options[i].opt.has_arg == optional_argument)
+               {
+                 shortopts[is] = ':';
+                 ++is;
+               }
            }
        }
       if (ld_options[i].opt.name != NULL)
@@ -423,6 +436,10 @@ parse_args (argc, argv)
        case OPTION_NON_SHARED:
          config.dynamic_link = false;
          break;
+       case OPTION_CREF:
+         command_line.cref = true;
+         link_info.notice_all = true;
+         break;
        case 'd':
          command_line.force_common_definition = true;
          break;
@@ -457,6 +474,9 @@ parse_args (argc, argv)
        case 'F':
          /* Ignore.  */
          break;
+       case OPTION_FORCE_EXE_SUFFIX:
+         command_line.force_exe_suffix = true;
+         break;
        case 'G':
          {
            char *end;
@@ -624,7 +644,7 @@ parse_args (argc, argv)
          set_section_start (".text", optarg);
          break;
        case OPTION_TRADITIONAL_FORMAT:
-         config.traditional_format = true;
+         link_info.traditional_format = true;
          break;
        case OPTION_UR:
          link_info.relocateable = true;
@@ -650,8 +670,23 @@ parse_args (argc, argv)
          version_printed = true;
          break;
        case OPTION_VERSION:
-         ldversion (0);
-         version_printed = true;
+         /* This output is intended to follow the GNU standards document.  */
+         printf ("GNU ld %s\n", ld_program_version);
+         printf ("Copyright 1996 Free Software Foundation, Inc.\n");
+         printf ("\
+This program is free software; you may redistribute it under the terms of\n\
+the GNU General Public License.  This program has absolutely no warranty.\n");
+         {
+           ld_emulation_xfer_type **ptr = ld_emulations;
+    
+           printf ("  Supported emulations:\n");
+           while (*ptr) 
+             {
+               printf ("   %s\n", (*ptr)->emulation_name);
+               ptr++;
+             }
+         }
+         xexit (0);
          break;
        case OPTION_WARN_COMMON:
          config.warn_common = true;
@@ -680,7 +715,7 @@ parse_args (argc, argv)
        case 'Y':
          if (strncmp (optarg, "P,", 2) == 0)
            optarg += 2;
-         default_dirlist = optarg;
+         default_dirlist = xstrdup (optarg);
          break;
        case 'y':
          add_ysym (optarg);
@@ -743,12 +778,11 @@ set_default_dirlist (dirlist_ptr)
     {
       p = strchr (dirlist_ptr, ':');
       if (p != NULL)
-       *p = 0;
-      if (*dirlist_ptr)
+       *p = '\0';
+      if (*dirlist_ptr != '\0')
        ldfile_add_library_path (dirlist_ptr, true);
       if (p == NULL)
        break;
-      *p = ':';
       dirlist_ptr = p + 1;
     }
 }
@@ -798,8 +832,13 @@ help ()
                  len += (comma ? 2 : 0) + 2;
                  if (ld_options[j].arg != NULL)
                    {
-                     printf (" %s", ld_options[j].arg);
-                     len += 1 + strlen (ld_options[j].arg);
+                     if (ld_options[j].opt.has_arg != optional_argument)
+                       {
+                         printf (" ");
+                         ++len;
+                       }
+                     printf ("%s", ld_options[j].arg);
+                     len += strlen (ld_options[j].arg);
                    }
                  comma = true;
                }
@@ -855,4 +894,5 @@ help ()
   printf ("%s: supported emulations: ", program_name);
   ldemul_list_emulations (stdout);
   printf ("\n");
+  printf ("\nReport bugs to bug-gnu-utils@prep.ai.mit.edu\n");
 }