Linking nominally incompatible object files

Nick Clifton nickc@redhat.com
Wed May 5 16:26:00 GMT 2004


Hi Bernd,

>So I have a mix of GCC-compiled v850 object files, and Green Hills v800
>(what I've called my "new" target) libraries.  When I link them all
>together, I get:
>
>lt-ld-new: warning: v850 architecture of input file `aim.o' is incompatible with v850e output
>lt-ld-new: warning: v850 architecture of input file `circbuf.o' is incompatible with v850e output
>  
>
Assuming that "lt-ld-new" is the GNU linker then this message is arising 
because the machine numbers of the two files are different.  These 
numbers are held in the e_machine field of the ELF header and the GNU 
linker is expecting one of the values defined in the bfd/archures.c file 
(bfd_mach_v850, bfd_mach_v850e, bfd_mach_v850e1).  The output file has 
its e_machine value filled in by using the value from the very first 
object file on the linker's command line.  This is usually a file like 
crt0.o.  So in this case the linker is telling you that the crt0.o file 
(or whichever is the first file in the link) is for a different version 
of the v850 than the aim.o file.

>reloc type 2 not SUPPORTED
>  
>
>The weird thing is, that aim.o is generated by the v850 toolchain, so
>its relocs cannot possibly be completely alien (if I link with the
>v850-ld and remove all the v800 libraries, the errors are "undefined
>reference", not "unsupported relocation").
>  
>
Reloc 2 is for a function call.  So if you remove the libraries then you 
are probably removing the definition of the function being called and 
hence the failure changes to "undefined reference".  I am not sure why 
you are getting the message that the reloc is not supported.  I think 
that some further investigation is needed.

>Is the linker supposed to interpret the relocs based on the input file
>format (would be nice) or based on the output file format?
>
Neither and both.  It is supposed to interpret them based on the target 
architecture that it was built to support.  When it is built to support 
more than one architecture then it is supposed to select the relocs that 
is supports based upon the input file that it is processing.  (It is 
also allowed to refuse to link together files of different architectural 
types if it thinks that it cannot handle this).

>Should I just give up now, while I can, before I involuntarily end up as
>a BFD hacker?
>  
>
Welcome to the dark side :-)

Cheers
  Nick



More information about the Binutils mailing list