* lib/ld-lib.exp (default_ld_simple_link): Permit the linker to
[deliverable/binutils-gdb.git] / ld / ldmain.c
index 13eb44875de5d6c644a0e3e920ff158f41994601..03dd31513fedaf14063b5f24f17fd8365967353c 100644 (file)
@@ -1,5 +1,5 @@
 /* Main program of GNU linker.
-   Copyright (C) 1991, 92, 93, 94, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
 This file is part of GLD, the Gnu Linker.
@@ -15,9 +15,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GLD; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
+along with GLD; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -46,6 +46,12 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307
 
 #include <string.h>
 
+#ifdef HAVE_SBRK
+#ifdef NEED_DECLARATION_SBRK
+extern PTR sbrk ();
+#endif
+#endif
+
 static char *get_emulation PARAMS ((int, char **));
 static void set_scripts_dir PARAMS ((void));
 
@@ -166,6 +172,16 @@ main (argc, argv)
 
   xatexit (remove_output);
 
+  /* Set the default BFD target based on the configured target.  Doing
+     this permits the linker to be configured for a particular target,
+     and linked against a shared BFD library which was configured for
+     a different target.  The macro TARGET is defined by Makefile.  */
+  if (! bfd_set_default_target (TARGET))
+    {
+      einfo ("%X%P: can't set BFD default target to `%s': %E\n", TARGET);
+      xexit (1);
+    }
+
   /* Initialize the data about options.  */
   trace_files = trace_file_tries = version_printed = false;
   whole_archive = false;
@@ -183,8 +199,6 @@ main (argc, argv)
   link_info.traditional_format = false;
   link_info.strip = strip_none;
   link_info.discard = discard_none;
-  link_info.lprefix_len = 1;
-  link_info.lprefix = "L";
   link_info.keep_memory = true;
   link_info.input_bfds = NULL;
   link_info.create_object_symbols_section = NULL;
@@ -323,6 +337,8 @@ main (argc, argv)
     lang_map ();
   if (command_line.cref)
     output_cref (config.map_file != NULL ? config.map_file : stdout);
+  if (nocrossref_list != NULL)
+    check_nocrossrefs ();
 
   /* Even if we're producing relocateable output, some non-fatal errors should
      be reported in the exit status.  (What non-fatal errors, if any, do we
@@ -425,7 +441,7 @@ get_emulation (argc, argv)
   char *emulation;
   int i;
 
-  emulation = (char *) getenv (EMULATION_ENVIRON);
+  emulation = getenv (EMULATION_ENVIRON);
   if (emulation == NULL)
     emulation = DEFAULT_EMULATION;
 
@@ -448,7 +464,8 @@ get_emulation (argc, argv)
            }
          else if (strcmp (argv[i], "-mips1") == 0
                   || strcmp (argv[i], "-mips2") == 0
-                  || strcmp (argv[i], "-mips3") == 0)
+                  || strcmp (argv[i], "-mips3") == 0
+                  || strcmp (argv[i], "-mips4") == 0)
            {
              /* FIXME: The arguments -mips1, -mips2 and -mips3 are
                 passed to the linker by some MIPS compilers.  They
@@ -787,8 +804,10 @@ multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
      FIXME: It would be cleaner to somehow ignore symbols defined in
      sections which are being discarded.  */
   if ((osec->output_section != NULL
+       && ! bfd_is_abs_section (osec)
        && bfd_is_abs_section (osec->output_section))
       || (nsec->output_section != NULL
+         && ! bfd_is_abs_section (nsec)
          && bfd_is_abs_section (nsec->output_section)))
     return true;
 
@@ -1031,6 +1050,9 @@ warning_callback (info, warning, symbol, abfd, section, address)
 
       if (! info.found)
        einfo ("%B: %s\n", abfd, warning);
+
+      if (entry == NULL)
+       free (asymbols);
     }
 
   return true;
@@ -1241,7 +1263,7 @@ notice (info, name, abfd, section, value)
           bfd_is_und_section (section) ? "reference to" : "definition of",
           name);
 
-  if (command_line.cref)
+  if (command_line.cref || nocrossref_list != NULL)
     add_cref (name, abfd, section, value);
 
   return true;
This page took 0.024062 seconds and 4 git commands to generate.