Bug 6937 - binutils 2.18 fails linking libopcodes.so due to missing symbols
Summary: binutils 2.18 fails linking libopcodes.so due to missing symbols
Status: RESOLVED DUPLICATE of bug 6768
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-02 19:47 UTC by Peter S. Mazinger
Modified: 2009-01-19 08:39 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: armv5te-softfloat-linux-uclibc
Build:
Last reconfirmed:


Attachments
Add libiberty.a to the shared lib adds (315 bytes, patch)
2008-10-09 12:55 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter S. Mazinger 2008-10-02 19:47:04 UTC
I tried to compile binutils-2.18 for armv5te-softfloat-linux-uclibc target with
LDFLAGS="-Wl,-z,defs". libopcodes.so fails to link due to missing symbols that
are in libiberty.a (floatformat_to_double and floatformat_ieee_single_little
used in arm-dis.c). The *cygwin targets already have a fix in cvs for this
adding -L`pwd`/../libiberty -liberty to SHARED_LIBADD (opcodes/configure.in),
probably the dependency has to fixed too, adding `pwd`/../libiberty/libiberty.a
to it

Additional comment:
haven't tried to compile the cvs sources, but reading the code arm-dis.c uses
the functions in floatformat, so it should have the same problem if it does not
link against libiberty.a. The *cygwin target is fixed (since cygwin will bail
out on undefined symbols), I do not really know if all other cases in cvs should
be fixed, the case I am speaking about is the host == * && host_vendor != hp in
opcodes/configure.in, although limited to arm*. Note: the only other arch using
in *-dis.c some floatformat function is m68k, so m68k is affected too
Comment 1 Nick Clifton 2008-10-03 15:34:45 UTC
Hi Peter,

  I have been trying to reproduce this problem but failing.  Please could you
show me a step-by-step guide as to how you made it happen ?

Cheers
  Nick
Comment 2 Peter S. Mazinger 2008-10-03 18:29:55 UTC
Subject: Re:  binutils 2.18 fails linking libopcodes.so due
 to missing symbols

I used a cross development script for this, it does something like

mkdir build; cd build; LDFLAGS="-Wl,-z,defs" ../binutils-2.18/configure --target=armv5te-softfloat-linux-uclibc

Peter
-------- Original-Nachricht --------
> Datum: 3 Oct 2008 15:34:45 -0000
> Von: "nickc at redhat dot com" <sourceware-bugzilla@sourceware.org>
> An: ps.m@gmx.net
> Betreff: [Bug binutils/6937] binutils 2.18 fails linking libopcodes.so due to missing symbols

> 
> ------- Additional Comments From nickc at redhat dot com  2008-10-03 15:34
> -------
> Hi Peter,
> 
>   I have been trying to reproduce this problem but failing.  Please could
> you
> show me a step-by-step guide as to how you made it happen ?
> 
> Cheers
>   Nick
> 
> 
> -- 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|NEW                         |WAITING
> 
> 
> http://sourceware.org/bugzilla/show_bug.cgi?id=6937
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.

Comment 3 Nick Clifton 2008-10-04 08:22:30 UTC
Subject: Re:  binutils 2.18 fails linking libopcodes.so
 due	to missing symbols

Hi Peter,

> mkdir build; cd build; LDFLAGS="-Wl,-z,defs" ../binutils-2.18/configure --target=armv5te-softfloat-linux-uclibc

That is exactly what I tried and yet it worked for me.  (I assume that 
you are using a bash like shell and a linux host, yes ?).

After the configure stage did you just run "make" or did you build the 
opcodes library on its own ?

Cheers
   Nick

Comment 4 Peter S. Mazinger 2008-10-07 18:52:07 UTC
I tried it with current cvs, the minimal configure that fails is:
mkdir build; cd build; LDFLAGS="-Wl,-z,defs" ../src/configure
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu
--target=armv5te-unknown-linux-uclibc --enable shared --disable-werror ; make all

disable-werror is only needed to avoid an earlier bailout on bfd/tekhex.c at
line 434: wrong argument for memcpy, enable-shared is the magic, since else it
won't try to compile shared libs on cross-build (shared would be enabled on a
native build, if supported by target)

Peter
Comment 5 Nick Clifton 2008-10-09 12:55:46 UTC
Created attachment 2985 [details]
Add libiberty.a to the shared lib adds
Comment 6 Nick Clifton 2008-10-09 12:57:04 UTC
Hi Peter,

  Thanks for mentioning --enable-shared.  That was the flag that I was missing
when I tried the test the first time.  I can now reproduce the problem and I
have a patch for you to try out.  If it works for you let me know and I will
check it in.

Cheers
  Nick
Comment 7 Peter S. Mazinger 2008-10-10 09:27:09 UTC
patch is ok, consider to add ../libiberty/libiberty.a as a dependency too
Comment 8 Nick Clifton 2008-10-10 11:35:40 UTC
Hi Peter,

  I have checked the patch in with the dependency added as suggested.

Cheers
  Nick

opcodes/ChangeLog
2008-10-10  Nick Clifton  <nickc@redhat.com>

	PR 6937
	* configure.in (SHARED_LIBADD): Add libiberty.a.
	(SHARED_DEPENDENCIES): Add libiberty.a.
Comment 9 Kirill A. Shutemov 2008-10-13 15:06:18 UTC
This change provokes text relocations. I guess, PIC version of libiberty.a
should be used.
Comment 10 Nick Clifton 2008-10-13 15:28:45 UTC
Subject: Re:  binutils 2.18 fails linking libopcodes.so
 due	to missing symbols

Hi Kirill,

> This change provokes text relocations.

Sorry - please could you explain what that means and why it is undesirable ?

> I guess, PIC version of libiberty.a should be used.

A PIC version of libiberty is not normally generated even if configure 
with --enable-shared...

Cheers
   Nick


Comment 11 Kirill A. Shutemov 2008-10-13 18:27:58 UTC
(In reply to comment #10)
> Subject: Re:  binutils 2.18 fails linking libopcodes.so
>  due	to missing symbols
> 
> Hi Kirill,
> 
> > This change provokes text relocations.
> 
> Sorry - please could you explain what that means and why it is undesirable ?

http://people.redhat.com/drepper/textrelocs.html

> 
> > I guess, PIC version of libiberty.a should be used.
> 
> A PIC version of libiberty is not normally generated even if configure 
> with --enable-shared...

Yep, you are right. :(
Then I have no ideas how to fix it.
Comment 12 Dmitry V. Levin 2008-10-13 22:56:21 UTC
(In reply to comment #10)
> > I guess, PIC version of libiberty.a should be used.
> 
> A PIC version of libiberty is not normally generated even if configure 
> with --enable-shared...

This is not a problem: the PIC version should be used iff it is built.
There is an appropriate configure check for PICFLAG in bfd/configure.in already.
Comment 13 Alan Modra 2008-10-14 00:38:52 UTC
I think Nick's patch is wrong.  :-(  We don't ever build a shared libiberty, and
libiberty.a usually contains non-pic objects.  So linking libiberty.a against
libopcodes.so will (depending on target) produce a libopcodes.so with text
relocations.

The way this used to work a very long time ago (binutils-2.8) was that
libiberty/pic/*.o were pulled in directly when building libopcodes.so or the
combined bfd and opcodes libbfd.so.  Note that this provided the entirety of
libiberty in libopcodes.so or libbfd.so, satisfying all of the binutils apps
references to libiberty functions.  I don't know why we lost this feature, or
how much work it would take to fix.
Comment 14 Nick Clifton 2008-10-14 08:20:08 UTC
Subject: Re:  binutils 2.18 fails linking libopcodes.so
 due	to missing symbols

> I think Nick's patch is wrong.  :-(

Doh!

>  We don't ever build a shared libiberty,

Why not ?  Wouldn't it be easy to solve this problem if we did build a 
shared libiberty ?
Comment 15 H.J. Lu 2008-10-14 11:41:10 UTC
(In reply to comment #14)
> Subject: Re:  binutils 2.18 fails linking libopcodes.so
>  due	to missing symbols
> 
> > I think Nick's patch is wrong.  :-(
> 
> Doh!
> 
> >  We don't ever build a shared libiberty,
> 
> Why not ?  Wouldn't it be easy to solve this problem if we did build a 
> shared libiberty ?
> 

You may run into problems of different shared libiberty libraries
from gcc and gdb/binutils.
Comment 16 Nick Clifton 2008-10-22 14:46:32 UTC
Hi Guys,

  Well - I do not know how to resolve this PR, but it seems obvious thatmy
original patch was wrong, so I am going to revert it.

Cheers
  Nick
Comment 17 Peter S. Mazinger 2008-10-22 18:13:07 UTC
earlier there was a PIC version of libiberty.a built in a subdirectory pic/ if
target supports it, maybe we could reenable it and use that to link,
alternatively libiberty.a could be always built PIC (PICFLAGS=-fPIC|-fpic),
although I think the second variant will get some objections...
Comment 18 Peter S. Mazinger 2008-10-22 18:19:48 UTC
forgot to mention, if libiberty.a is not PIC, it will be buggy for cygwin too
and if it is installed into any target (the binutils provided libiberty.a is
usually installed on most distros I saw), it is not allowed to be linked into
any shared library or PIE executable, since it will produce text relocations as
well. Some apps providing only archive without shared library produce
alternatively a lib*_pic.a file, meaning that all objects that went into it are
-fPIC|-fpic compiled.

Peter
Comment 19 Alan Modra 2009-01-19 08:39:35 UTC
This bug has been partly fixed with my 2009-01-16 opcodes commit, in that
libopcodes will now contain the pic libiberty functions if they are available. 
Using uclibc will still result in -zdefs errors due to needing libm, but that is
convered by http://sourceware.org/bugzilla/show_bug.cgi?id=6768, so closing and
marking this a dup.

*** This bug has been marked as a duplicate of 6768 ***