bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/14773] ld --as-needed reports undefined reference in the wrong l


From: amodra at gmail dot com
Subject: [Bug ld/14773] ld --as-needed reports undefined reference in the wrong library
Date: Thu, 01 Nov 2012 06:51:03 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=14773

Alan Modra <amodra at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |amodra at gmail dot com
         Resolution|                            |INVALID

--- Comment #2 from Alan Modra <amodra at gmail dot com> 2012-11-01 06:51:03 
UTC ---
I'll note that ld is correct to give an error here.  At the point you try to
link libX11.so, there are no references from regular object files to
XFillRectangle so since --as-needed is in force, ld decides that libX11.so is
not needed.  You then link libstatic.a, pulling in an object file that
references XFillRectangle and thus generate an error.  If you don't mention
-lX11 on the command line, then libX11.so will be (somewhat magically) included
in the link because it is listed as dependency of libshared.so.  This doesn't
happen if ld has already decided the library isn't needed.

You also won't get an error if you put -lX11 last, which is really the only
sane place to put it when you know your libstatic.a references libX11.so
functions..

Your claim "XFillRectangle isn't an undefined symbol in libshared.so" is false
too, so the ld error message is correct.  ld only remembers the first place the
symbol was seen as undefined.  Again, it doesn't pay to put shared libraries
before object files or archives.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]