Eliminate false DVs on parallel compares.
[deliverable/binutils-gdb.git] / ld / ldmain.c
index 734bc32f05df22a0e71add713ec97dd57a37c9b8..fea1244154aefe72aaf18a9145d664649acc8346 100644 (file)
@@ -1,5 +1,5 @@
 /* Main program of GNU linker.
-   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
@@ -27,6 +27,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "libiberty.h"
 #include "progress.h"
 #include "bfdlink.h"
+#include "filenames.h"
 
 #include "ld.h"
 #include "ldmain.h"
@@ -35,9 +36,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "ldgram.h"
 #include "ldexp.h"
 #include "ldlang.h"
-#include "ldemul.h"
 #include "ldlex.h"
 #include "ldfile.h"
+#include "ldemul.h"
 #include "ldctor.h"
 
 /* Somewhere above, sys/stat.h got included . . . . */
@@ -117,7 +118,7 @@ static boolean warning_callback PARAMS ((struct bfd_link_info *,
 static void warning_find_reloc PARAMS ((bfd *, asection *, PTR));
 static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
                                         const char *, bfd *,
-                                        asection *, bfd_vma));
+                                        asection *, bfd_vma, boolean));
 static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
                                       const char *, bfd_vma,
                                       bfd *, asection *, bfd_vma));
@@ -199,6 +200,8 @@ main (argc, argv)
   config.build_constructors = true;
   config.dynamic_link = false;
   config.has_shared = false;
+  config.split_by_reloc = (unsigned) -1;
+  config.split_by_file = (bfd_size_type) -1;
   command_line.force_common_definition = false;
   command_line.interpreter = NULL;
   command_line.rpath = NULL;
@@ -214,6 +217,7 @@ main (argc, argv)
 
   link_info.callbacks = &link_callbacks;
   link_info.relocateable = false;
+  link_info.emitrelocations = false;
   link_info.shared = false;
   link_info.symbolic = false;
   link_info.static_link = false;
@@ -235,6 +239,9 @@ main (argc, argv)
      and _fini symbols.  We are compatible.  */
   link_info.init_function = "_init";
   link_info.fini_function = "_fini";
+  link_info.new_dtags = false;
+  link_info.flags = (bfd_vma) 0;
+  link_info.flags_1 = (bfd_vma) 0;
 
   ldfile_add_arch ("");
 
@@ -346,15 +353,17 @@ main (argc, argv)
   /* Print error messages for any missing symbols, for any warning
      symbols, and possibly multiple definitions */
 
-
-  if (config.text_read_only)
+  if (! link_info.relocateable)
     {
-      /* Look for a text section and mark the readonly attribute in it */
-      asection *found = bfd_get_section_by_name (output_bfd, ".text");
-
+      /* Look for a text section and switch the readonly attribute in it.  */
+      asection * found = bfd_get_section_by_name (output_bfd, ".text");
+    
       if (found != (asection *) NULL)
        {
-         found->flags |= SEC_READONLY;
+         if (config.text_read_only)
+           found->flags |= SEC_READONLY;
+         else
+           found->flags &= ~SEC_READONLY;
        }
     }
 
@@ -567,6 +576,14 @@ set_scripts_dir ()
 
   /* Look for "ldscripts" in the dir where our binary is.  */
   end = strrchr (program_name, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+  {
+    /* We could have \foo\bar, or /foo\bar.  */
+    char *bslash = strrchr (program_name, '\\');
+    if (end == NULL || (bslash != NULL && bslash > end))
+      end = bslash;
+  }
+#endif
 
   if (end == NULL)
     {
@@ -846,6 +863,13 @@ multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
         nbfd, nsec, nval, name);
   if (obfd != (bfd *) NULL)
     einfo (_("%D: first defined here\n"), obfd, osec, oval);
+
+  if (command_line.relax)
+    {
+      einfo (_("%P: Disabling relaxation: it will not work with multiple definitions\n"));
+      command_line.relax = 0;
+    }
+  
   return true;
 }
 
@@ -1144,12 +1168,13 @@ warning_find_reloc (abfd, sec, iarg)
 
 /*ARGSUSED*/
 static boolean
-undefined_symbol (info, name, abfd, section, address)
+undefined_symbol (info, name, abfd, section, address, fatal)
      struct bfd_link_info *info ATTRIBUTE_UNUSED;
      const char *name;
      bfd *abfd;
      asection *section;
      bfd_vma address;
+     boolean fatal ATTRIBUTE_UNUSED;
 {
   static char *error_name;
   static unsigned int error_count;
@@ -1193,8 +1218,12 @@ undefined_symbol (info, name, abfd, section, address)
   if (section != NULL)
     {
       if (error_count < MAX_ERRORS_IN_A_ROW)
-       einfo (_("%X%C: undefined reference to `%T'\n"),
-              abfd, section, address, name);
+       {
+         einfo (_("%C: undefined reference to `%T'\n"),
+                abfd, section, address, name);
+         if (fatal)
+           einfo ("%X");
+       }
       else if (error_count == MAX_ERRORS_IN_A_ROW)
        einfo (_("%D: more undefined references to `%T' follow\n"),
               abfd, section, address, name);
@@ -1202,8 +1231,12 @@ undefined_symbol (info, name, abfd, section, address)
   else
     {
       if (error_count < MAX_ERRORS_IN_A_ROW)
-       einfo (_("%X%B: undefined reference to `%T'\n"),
-              abfd, name);
+       {
+         einfo (_("%B: undefined reference to `%T'\n"),
+                abfd, name);
+         if (fatal)
+           einfo ("%X");
+       }
       else if (error_count == MAX_ERRORS_IN_A_ROW)
        einfo (_("%B: more undefined references to `%T' follow\n"),
               abfd, name);
This page took 0.024853 seconds and 4 git commands to generate.