public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] skipping of incompatible libraries in the search path
@ 1999-07-05  9:37 Jakub Jelinek
  1999-07-08 16:51 ` Richard Henderson
  1999-07-09 22:54 ` Ian Lance Taylor
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 1999-07-05  9:37 UTC (permalink / raw)
  To: binutils

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)
___________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] skipping of incompatible libraries in the search path
  1999-07-05  9:37 [PATCH] skipping of incompatible libraries in the search path Jakub Jelinek
@ 1999-07-08 16:51 ` Richard Henderson
  1999-07-09 22:54 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1999-07-08 16:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Mon, Jul 05, 1999 at 06:37:46PM +0200, Jakub Jelinek wrote:
> 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.

Applied.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] skipping of incompatible libraries in the search path
  1999-07-05  9:37 [PATCH] skipping of incompatible libraries in the search path Jakub Jelinek
  1999-07-08 16:51 ` Richard Henderson
@ 1999-07-09 22:54 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 1999-07-09 22:54 UTC (permalink / raw)
  To: jj; +Cc: binutils, rth

   Date: Mon, 5 Jul 1999 18:37:46 +0200
   From: Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>

   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.

Thanks for sending this patch.

I wasn't particularly happy with the implementation, so I changed it
to do the test in ldfile_try_open_bfd instead (that is, I reverted the
code that Richard checked in, and checked in a different patch).
Checking in ldfile_try_open_bfd should work for shared libraries as
well as for static libraries--I can't see any reason why shared
libraries should behave differently.  I also changed the patch so that
it only checks the first object in a static library-- because of the
way that archive maps work, I don't see any reliable way to use an
archive which has objects of incompatible architecture anyhow.

Please let me know if I messed up the changes.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-07-09 22:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-05  9:37 [PATCH] skipping of incompatible libraries in the search path Jakub Jelinek
1999-07-08 16:51 ` Richard Henderson
1999-07-09 22:54 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).