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]

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


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




Nick Clifton (2):
  * elflink.c (elf_link_add_object_symbols): Improve error            
    message generated when a symbol is left unresolved because a       
         --no-add-needed command line option has prevented the         
       inclusion of the DSO defining it.
  * elflink.c (elf_link_add_object_symbols): Look up name of           
     undefined symbol both before and after versioning has been        
        applied.  Do not bother with symbols that are weakly undefined.

Roland McGrath (1):
  Fix %s that should be %B in several message formats.

 bfd/ChangeLog |   28 ++++++++++++++++++++++++++++
 bfd/elflink.c |   51 ++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 70 insertions(+), 9 deletions(-)

-- 
1.7.2.1.44.g721e7


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