* emultempl/ppc64elf.em: Convert to C90 function definitions, remove
[deliverable/binutils-gdb.git] / ld / ldmain.c
index 214847d9a0571fe90c2f81bf875660dea3a931c9..08a0ec4bc6b5a9ae25aab30da4a18e91c61ffb27 100644 (file)
@@ -72,6 +72,10 @@ char *program_name;
 /* The prefix for system library directories.  */
 char *ld_sysroot;
 
+/* The canonical representation of ld_sysroot.  */
+char * ld_canon_sysroot;
+int ld_canon_sysroot_len;
+
 /* The file that we're creating.  */
 bfd *output_bfd = 0;
 
@@ -151,7 +155,8 @@ static struct bfd_link_callbacks link_callbacks =
   reloc_overflow,
   reloc_dangerous,
   unattached_reloc,
-  notice
+  notice,
+  error_handler
 };
 
 struct bfd_link_info link_info;
@@ -234,6 +239,14 @@ main (argc, argv)
 #endif
     ld_sysroot = TARGET_SYSTEM_ROOT;
 
+  if (ld_sysroot && *ld_sysroot)
+    ld_canon_sysroot = lrealpath (ld_sysroot);
+
+  if (ld_canon_sysroot)
+    ld_canon_sysroot_len = strlen (ld_canon_sysroot);
+  else
+    ld_canon_sysroot_len = -1;
+
   /* 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
@@ -278,6 +291,8 @@ main (argc, argv)
   link_info.emitrelocations = FALSE;
   link_info.task_link = FALSE;
   link_info.shared = FALSE;
+  link_info.pie = FALSE;
+  link_info.executable = FALSE;
   link_info.symbolic = FALSE;
   link_info.export_dynamic = FALSE;
   link_info.static_link = FALSE;
@@ -316,6 +331,7 @@ main (argc, argv)
   link_info.spare_dynamic_tags = 5;
   link_info.flags = (bfd_vma) 0;
   link_info.flags_1 = (bfd_vma) 0;
+  link_info.relax_finalizing = FALSE;
 
   ldfile_add_arch ("");
 
@@ -354,6 +370,9 @@ main (argc, argv)
        einfo (_("%P%F: -f may not be used without -shared\n"));
     }
 
+  if (! link_info.shared || link_info.pie)
+    link_info.executable = TRUE;
+
   /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols).  I
      don't see how else this can be handled, since in this case we
      must preserve all externally visible symbols.  */
@@ -660,22 +679,25 @@ set_scripts_dir ()
 {
   char *end, *dir;
   size_t dirlen;
+  bfd_boolean found;
 
   dir = make_relative_prefix (program_name, BINDIR, SCRIPTDIR);
-  if (dir && check_for_scripts_dir (dir))
-    /* Success.  Don't free dir.  */
-    return;
-
   if (dir)
-    free (dir);
+    {
+      found = check_for_scripts_dir (dir);
+      free (dir);
+      if (found)
+       return;
+    }
 
   dir = make_relative_prefix (program_name, TOOLBINDIR, SCRIPTDIR);
-  if (dir && check_for_scripts_dir (dir))
-    /* Success.  Don't free dir.  */
-    return;
-
   if (dir)
-    free (dir);
+    {
+      found = check_for_scripts_dir (dir);
+      free (dir);
+      if (found)
+       return;
+    }
 
   if (check_for_scripts_dir (SCRIPTDIR))
     /* We've been installed normally.  */
@@ -706,15 +728,14 @@ set_scripts_dir ()
   dir[dirlen] = '\0';
 
   if (check_for_scripts_dir (dir))
-    /* Don't free dir.  */
-    return;
+    {
+      free (dir);
+      return;
+    }
 
   /* Look for "ldscripts" in <the dir where our binary is>/../lib.  */
   strcpy (dir + dirlen, "/../lib");
-  if (check_for_scripts_dir (dir))
-    return;
-
-  /* Well, we tried.  */
+  check_for_scripts_dir (dir);
   free (dir);
 }
 
@@ -820,6 +841,7 @@ add_keepsyms_file (filename)
   if (link_info.strip != strip_none)
     einfo (_("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"));
 
+  free (buf);
   link_info.strip = strip_some;
 }
 \f
@@ -1345,6 +1367,15 @@ undefined_symbol (info, name, abfd, section, address, fatal)
   return TRUE;
 }
 
+/* Counter to limit the number of relocation overflow error messages
+   to print.  Errors are printed as it is decremented.  When it's
+   called and the counter is zero, a final message is printed
+   indicating more relocations were omitted.  When it gets to -1, no
+   such errors are printed.  If it's initially set to a value less
+   than -1, all such errors will be printed (--verbose does this).  */
+
+int overflow_cutoff_limit = 10;
+
 /* This is called when a reloc overflows.  */
 
 static bfd_boolean
@@ -1357,10 +1388,21 @@ reloc_overflow (info, name, reloc_name, addend, abfd, section, address)
      asection *section;
      bfd_vma address;
 {
+  if (overflow_cutoff_limit == -1)
+    return TRUE;
+
   if (abfd == (bfd *) NULL)
     einfo (_("%P%X: generated"));
   else
     einfo ("%X%C:", abfd, section, address);
+
+  if (overflow_cutoff_limit >= 0
+      && overflow_cutoff_limit-- == 0)
+    {
+      einfo (_(" additional relocation overflows omitted from the output\n"));
+      return TRUE;
+    }
+
   einfo (_(" relocation truncated to fit: %s %T"), reloc_name, name);
   if (addend != 0)
     einfo ("+%v", addend);
This page took 0.025838 seconds and 4 git commands to generate.