Sources Bugzilla – Bug 4424
Can't link in Linux object files on FreeBSD
Last modified: 2009-03-03 11:03:53 UTC
elf_link_add_object_symbols has if (! dynamic && is_elf_hash_table (htab) && htab->root.creator == abfd->xvec && bed->check_relocs != NULL) When you link Linux object files on FreeBSD, htab->root.creator != abfd->xvec. As the result, linker will fail later. We need a better way to check if input format is compatible with output format.
A patch is posted at http://sourceware.org/ml/binutils/2007-04/msg00330.html
An updated patch is at http://sourceware.org/ml/binutils/2007-04/msg00331.html
An updated patch is posted at http://sourceware.org/ml/binutils/2007-08/msg00462.html
An updated patch for i386/FreeBSD is posted at http://sourceware.org/ml/binutils/2007-10/msg00215.html
*** Bug 5179 has been marked as a duplicate of this bug. ***
Created attachment 2043 [details] Link all sparc64 objects too We need this for FreeBSD/Sparc64 as well. Thanks!
A new patch is posted at http://sourceware.org/ml/binutils/2007-10/msg00240.html
The current patch is at http://sourceware.org/ml/binutils/2007-10/msg00257.html
http://sourceware.org/ml/binutils/2007-10/msg00262.html
We missed a case of linking Linux .o against FreeBSD .so: [hjl@gnu-6 weak-11]$ cat foo.c extern void xxxx () __attribute__((weak)); void _start(void) { if (&xxxx != 0) xxxx (); } [hjl@gnu-6 weak-11]$ cat bar.c void __attribute__((weak)) xxxx () { } [hjl@gnu-6 weak-11]$ make gcc -O2 -fno-asynchronous-unwind-tables -c -o foo.o foo.c gcc -O2 -fno-asynchronous-unwind-tables -fPIC -c -o bar.o bar.c ./ld -shared -o libbar.so bar.o ./ld -o foo foo.o libbar.so readelf -s foo | grep xxxx 1: 00000000004002a0 2 FUNC GLOBAL DEFAULT UND xxxx 15: 00000000004002a0 2 FUNC GLOBAL DEFAULT UND xxxx [hjl@gnu-6 weak-11]$ ./ld -V GNU ld (GNU Binutils) 2.18.50.20080715 Supported emulations: elf_x86_64_fbsd elf_i386_fbsd elf_x86_64 elf_i386 [hjl@gnu-6 weak-11]$ It should be readelf -s foo | grep xxxx 1: 00000000004002a0 2 FUNC WEAK DEFAULT UND xxxx 15: 00000000004002a0 2 FUNC WEAK DEFAULT UND xxxx
A new patch is posted at http://sourceware.org/ml/binutils/2008-07/msg00207.html
Patch was applied