This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2_20 0/3] ld: Fix -no-add-needed vs weak for binutils-2_20-branch


On Sat, Aug 07, 2010 at 06:32:39PM +0400, Kirill Smelkov wrote:
> Hello up there!
> 
> I'm from Debian land where we'll use binutils 2.20 for the next release.
> 
> However as you've probably already learned from Fedora DSO Link Change,
> -no-add-needed was breaking cases with weak symbols involved. In particular
> when linking C++ programs to libraries linked to libpthread.so without
> -lpthread for program itself was problematic -- See e.g. this thread
> 
>     http://www.mail-archive.com/devel@lists.fedoraproject.org/msg00042.html
> 
> and my example:
> 
> ---- 8< Makefile ----
> # $ make
> # g++ -Wl,-no-add-needed -shared -o lpthread.so -lpthread
> # g++ -Wl,-no-add-needed -o deb591405 deb591405.cpp lpthread.so 
> # /usr/bin/ld: ,: invalid DSO for symbol `pthread_cancel@@GLIBC_2.0' definition
> # /lib/libpthread.so.0: could not read symbols: Bad value
> CXX     := g++
> CXXLD   := $(CXX) -Wl,-no-add-needed
> #CXXLD  := $(CXX)
> 
> deb591405: deb591405.cpp lpthread.so
>         $(CXXLD) -o $@ $+ 
> 
> lpthread.so:
>         $(CXXLD) -shared -o $@ -lpthread
> 
> 
> ---- 8< deb591405.cpp -----
> /* c++-progs -> library -> pthread
>  *
>  * 1. library links to pthread explicitly
>  * 2. c++-prog does not link to pthread
>  *
>  * 3. libstdc++ weakly pulls pthread_cancel, which confuses linker when
>  *    building with -Wl,no-add-needed
>  *
>  * See http://bugs.debian.org/591405
>  */
> 
> #include <string>
> #include <iostream>
> using namespace std;
> 
> int main()
> {
>     string msg = "I hope Debian bug #591405 has been fixed!\n";
> 
>     cout << msg;
>     return 0;
> }
> 
> 
> 
> Things are fixed on binutils trunk, but binutils-2_20-branch still has the
> problem.
> 
> Is it somehow possible to please apply fixes to 2.20 too? If yes, I've
> prepared backported patches, which go as replies to this email.
> 
> 
> Thanks beforehand,
> Kirill

Silence ...


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]