undefined reference when mixing a.out and ELF object files ?

Nick Clifton nickc@redhat.com
Fri May 2 06:51:00 GMT 2008


Hi Vincent,

> The problem is something like this.
> a.o is an ELF object file containing an undefined symbol
> b.o is an a.out object file defining the symbol.
> 
> If the ld output format is ELF, the link success.
> If the ld output format is a.out or "binary", the link fails with 
> "undefined reference".
> 
> If I convert b.o to ELF using objcopy, the link succeed in every case.
> 
> That sounds like a bug... or maybe I'm trying to make an unsupported mix?

It is probably an unsupported mix.  There are quite a few cases already 
where the linker cannot handle converting being object file formats at 
the same time as performing a final link.  The safest method is to 
convert b.o to ELF first and then link it with a.o second.

The only real bug in this case is that the linker should be detecting an 
attempt to link-and-convert for a combination that it does not support 
and then issuing an appropriate error message.

Cheers
   Nick




More information about the Binutils mailing list