[PATCH] skipping of incompatible libraries in the search path

Jakub Jelinek jj@sunsite.ms.mff.cuni.cz
Mon Jul 5 09:37:00 GMT 1999


Hi!

This is a patch for how I think the skip on mismatch discussion ended.
It makes ld skip incompatible libraries unconditionally, but lets the user
know about it whenever it happens. If the user wants to force linking an
incompatible library in, he has to request it by supplying full path to the
library.

1999-07-05  Jakub Jelinek  <jj@ultra.linux.cz>

	* ld/ldfile.c (ldfile_open_file_search): Skip libraries made for
	incompatible architectures in the search path. Let the user know
	about any such skips.

--- ./ldfile.c.jj	Mon May  3 09:29:06 1999
+++ ./ldfile.c	Mon Jul  5 18:12:21 1999
@@ -177,8 +177,35 @@ ldfile_open_file_search (arch, entry, li
 
       if (ldfile_try_open_bfd (string, entry))
 	{
-	  entry->filename = string;
-	  return true;
+	  bfd * arfile = NULL;
+
+	  if (bfd_check_format (entry->the_bfd, bfd_archive))
+	    {
+	      /* We treat an archive as compatible if it empty
+	         or has at least one compatible object.  */
+	      arfile = bfd_openr_next_archived_file (entry->the_bfd, NULL);
+
+	      if (!arfile)
+		arfile = output_bfd;
+	      else
+		while (arfile
+		       && !(bfd_check_format (arfile, bfd_object)
+			    && bfd_arch_get_compatible (arfile, output_bfd)))
+	          arfile = bfd_openr_next_archived_file (entry->the_bfd, arfile);
+	    }
+	  else if (bfd_arch_get_compatible (entry->the_bfd, output_bfd))
+	    arfile = output_bfd;
+	    
+	  if (arfile)
+	    {
+	      entry->filename = string;
+	      return true;
+	    }
+
+	  info_msg (_("skipping %s because it has incompatible architecture\n"), string);
+	  bfd_close(entry->the_bfd);
+	  entry->the_bfd = NULL;
+	                                              
 	}
 
       free (string);


Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux  |  http://ultra.linux.cz/  |  http://ultra.penguin.cz/
Linux version 2.2.10 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________


More information about the Binutils mailing list