This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Binutuls is broken now.


Hi H.J.

> Given what we know, if my patch is not acceptable to everyone, may I
> suggest we revert the patch:
> 
> 2001-06-15  Hans-Peter Nilsson  <hp@axis.com>
> 
>         * ldlang.c (lang_check): Emit fatal error if relocatable link
>         between different object flavours.
> 
> We can find some better ways to deal with it later.

No I do not think that that is right.  Hans-Peter's patch is catching
a valid user mistake, and I believe that we do now agree that your
supplemental patch was basically correct.

Thus I am proposing that we apply the patch below.  It incorporates
Hans-Pater's original patch to catch mixed format relocatable links,
plus your patch to allow the binary format in otherwise homogeneous
relocatable links, plus it adds a couple of comments to explain what
it going on.

One thing I did miss out from H.J.'s patch was the tests to make sure
that the input and/or output formats were not undefined.  It seemed to
me that the tests were unnecessary since the earlier line has ensured
that at least one of the formats must be defined, and trying to
(relocatably) link an undefined format with a defined one is bound to
fail.

So what do you guys think.  Is there any reason not to apply this
patch ?

Cheers
        Nick

2001-06-19  Nick Clifton  <nickc@cambridge.redhat.com>

	* ldlang.c (lang_check): Restore change made on 2001-06-15.
          Add code to allow "binary" format in otherwise homogeneous
          relocatable links.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.53
diff -p -r1.53 ldlang.c
*** ldlang.c	2001/06/19 14:39:02	1.53
--- ldlang.c	2001/06/19 16:05:40
*************** lang_check ()
*** 3520,3525 ****
--- 3520,3544 ----
  		   bfd_printable_name (input_bfd), input_bfd,
  		   bfd_printable_name (output_bfd));
  	}
+       else if (link_info.relocateable
+ 	       /* In general it is not possible to perform a relocatable link
+ 		  between differing object formats because the relocations in
+ 		  the input format may not have equivalent representations in
+ 		  the output format (and besides BFD does not translate relocs).  */
+ 	       && bfd_get_flavour (input_bfd) != bfd_get_flavour (output_bfd)
+ 	       /* If however, the input format does not have relocs then it is
+ 		  possible to translate it.  To check for this properly we would
+ 		  have to iterate over all of the input sections (that are going
+ 		  to be mapped into output sections) and check their HAS_RELOC
+ 		  flag.  For now we just allow the binary input format since we
+ 		  know that that format does not support relocs (and because we
+ 		  know that this technique is used by the linux kernel).
+ 		  FIXME: Remove this test and add a proper check once output
+ 		  sections have been assigned.  */
+ 	       && strcmp (bfd_get_target (input_bfd), "binary") != 0)
+  	einfo (_("%P%F: Relocatable linking from format %s (%B) to format %s (%B) is not supported\n"),
+  	       bfd_get_target (input_bfd), input_bfd,
+  	       bfd_get_target (output_bfd), output_bfd);
        else if (bfd_count_sections (input_bfd))
  	{
  	  /* If the input bfd has no contents, it shouldn't set the


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]