add MAINTAINERS files
[binutils-gdb.git] / ld / ldmain.c
index 734bc32f05df22a0e71add713ec97dd57a37c9b8..660ea94265aba28de81df46e14433913006959b2 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"
@@ -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));
@@ -214,6 +215,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;
@@ -346,15 +348,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 +571,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)
     {
@@ -1144,12 +1156,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 +1206,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 +1219,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);