This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 4424
  Can't link in Linux object files on FreeBSD Last modified: 2009-03-03 11:03:53
     Query page      Enter new bug
Bug#: 4424   Hardware:   Reporter: H.J. Lu <hjl.tools@gmail.com>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: unassigned@sources.redhat.com   Target Milestone:  
Summary:
Keywords:

Attachment Description Type Created Actions
binutils-link.patch Link all sparc64 objects too patch 2007-10-16 10:01 Edit | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 4424 depends on: Show dependency tree
Show dependency graph
Bug 4424 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2007-04-24 23:09
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.

------- Additional Comment #1 From H.J. Lu 2007-04-25 00:01 -------
A patch is posted at

http://sourceware.org/ml/binutils/2007-04/msg00330.html

------- Additional Comment #2 From H.J. Lu 2007-04-25 02:33 -------
An updated patch is at

http://sourceware.org/ml/binutils/2007-04/msg00331.html

------- Additional Comment #3 From H.J. Lu 2007-08-30 17:39 -------
An updated patch is posted at

http://sourceware.org/ml/binutils/2007-08/msg00462.html

------- Additional Comment #4 From H.J. Lu 2007-10-15 17:13 -------
An updated patch for i386/FreeBSD is posted at

http://sourceware.org/ml/binutils/2007-10/msg00215.html

------- Additional Comment #5 From H.J. Lu 2007-10-15 17:13 -------
*** Bug 5179 has been marked as a duplicate of this bug. ***

------- Additional Comment #6 From Roy Marples 2007-10-16 10:01 -------
Created an attachment (id=2043)
Link all sparc64 objects too

We need this for FreeBSD/Sparc64 as well. Thanks!

------- Additional Comment #7 From H.J. Lu 2007-10-16 17:56 -------
A new patch is posted at

http://sourceware.org/ml/binutils/2007-10/msg00240.html

------- Additional Comment #8 From H.J. Lu 2007-10-18 01:31 -------
The current patch is at

http://sourceware.org/ml/binutils/2007-10/msg00257.html

------- Additional Comment #9 From Alan Modra 2008-01-17 04:46 -------
http://sourceware.org/ml/binutils/2007-10/msg00262.html

------- Additional Comment #10 From H.J. Lu 2008-07-15 17:22 -------
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

------- Additional Comment #11 From H.J. Lu 2008-07-15 17:34 -------
A new patch is posted at

http://sourceware.org/ml/binutils/2008-07/msg00207.html

------- Additional Comment #12 From Alan Modra 2009-03-03 11:03 -------
Patch was applied

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In