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]
Other format: [Raw text]

Re: Not linking 32-bit and 64-bit objects


On Tue, Mar 12, 2002 at 11:32:15AM -0500, Daniel Jacobowitz wrote:
> On Tue, Mar 12, 2002 at 10:15:56PM +1030, Alan Modra wrote:
> > On Tue, Mar 12, 2002 at 12:05:47PM +0100, Andreas Jaeger wrote:
> > > 
> > > If I try to link a 32-bit i386 object as 64-bit x86-64 object, it
> > > should fail but I'd like to see a better error message.
> > 
> > I think you're probably better off writing a replacement for
> > bfd_default_compatible in bfd/cpu-i386.c
> 
> Is there any architecture where linking together objects with a
> different bits_per_word is really legal?

Depends on what you mean by "legal".  From a BFD viewpoint, where we
try to link anything with everything, the real problem is that BFD
currently fails when attempting to process relocs for the foreign
word size.  The ELF linker should treat these files similarly to
non-ELF files.  ie. The test at elflink.h:5331

	  if (p->type == bfd_indirect_link_order
	      && (bfd_get_flavour (p->u.indirect.section->owner)
		  == bfd_target_elf_flavour))

needs to test for wordsize too.

>From a user viewpoint, I'm not sure of the right answer.  I'd guess
that in most cases where this situation arises, it's because the
user inadvertently linked against the wrong library.  However, if
we prohibit this, someone is sure to complain that his "simple"
object with the wrong word-size won't link.  Maybe I was a little
hasty telling Andreas to change cpu-i386.c, but let's not revert
it just yet. :)

Ian, can I bother you for an opinion?

>  If not, adding it to
> bfd_default_compatible seems like the logical step.  For instance, I
> don't think MIPS-ELF32 and MIPS-ELF64 could really be linked together.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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