Summary: | linking against libs that require pthreads breaks due to symbol changes | ||
---|---|---|---|
Product: | binutils | Reporter: | Mike Frysinger <vapier> |
Component: | ld | Assignee: | H.J. Lu <hjl.tools> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 2.26 | ||
Target Milestone: | 2.27 | ||
Host: | Target: | x86_64-linux-gnu | |
Build: | Last reconfirmed: | ||
Bug Depends on: | 18720 | ||
Bug Blocks: |
Description
Mike Frysinger
2016-02-01 21:08:52 UTC
[hjl@gnu-6 pr19553]$ cat pr19553a.c extern void foo (void); int main (void) { foo (); return 0; } [hjl@gnu-6 pr19553]$ cat pr19553b.c #include <stdio.h> __attribute__ ((weak)) void foo (void) { printf ("pr19553b\n"); } [hjl@gnu-6 pr19553]$ cat pr19553c.c #include <stdio.h> void foo (void) { printf ("pr19553c\n"); } asm (".symver foo,foo@FOO"); [hjl@gnu-6 pr19553]$ cat pr19553d.c #include <stdio.h> __attribute__ ((weak)) void foo (void) { printf ("pr19553d\n"); } [hjl@gnu-6 pr19553]$ cat pr19553.map FOO { global: foo; }; [hjl@gnu-6 pr19553]$ make gcc -B./ -O2 -O2 -c -o pr19553a.o pr19553a.c gcc -B./ -O2 -fPIC -c -o pr19553d.o pr19553d.c gcc -B./ -O2 -fPIC -c -o pr19553c.o pr19553c.c gcc -B./ -shared -o libpr19553c.so pr19553c.o -Wl,--version-script=pr19553.map gcc -B./ -shared -o libpr19553d.so pr19553d.o libpr19553c.so gcc -B./ -O2 -fPIC -c -o pr19553b.o pr19553b.c gcc -B./ -shared -o libpr19553b.so pr19553b.o -Wl,--version-script=pr19553.map gcc -B./ -o x pr19553a.o libpr19553d.so libpr19553b.so -Wl,-R. ./ld: libpr19553d.so: undefined reference to symbol 'foo@FOO' ./libpr19553c.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status Makefile:23: recipe for target 'x' failed make: *** [x] Error 1 [hjl@gnu-6 pr19553]$ A patch is posted at https://sourceware.org/ml/binutils/2016-02/msg00035.html The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aef28989904e92e391fee905e51abc6bb2fd4de0 commit aef28989904e92e391fee905e51abc6bb2fd4de0 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Feb 1 15:49:52 2016 -0800 Don't add DT_NEEDED for unmatched symbol Don't add DT_NEEDED if a symbol from a library loaded via DT_NEEDED doesn't match the symbol referenced by regular object. bfd/ PR ld/19553 * elflink.c (elf_link_add_object_symbols): Don't add DT_NEEDED if a symbol from a library loaded via DT_NEEDED doesn't match the symbol referenced by regular object. ld/testsuite/ PR ld/19553 * testsuite/ld-elf/indirect.exp: Run tests for PR ld/19553. * testsuite/ld-elf/pr19553.map: New file. * testsuite/ld-elf/pr19553.map: Likewise. * testsuite/ld-elf/pr19553a.c: Likewise. * testsuite/ld-elf/pr19553b.c: Likewise. * testsuite/ld-elf/pr19553b.out: Likewise. * testsuite/ld-elf/pr19553c.c: Likewise. * testsuite/ld-elf/pr19553c.out: Likewise. * testsuite/ld-elf/pr19553d.c: Likewise. * testsuite/ld-elf/pr19553d.out: Likewise. Fixed for 2.27 so far. The binutils-2_26-branch branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f558a73bafecee6d3cd45031e44e6e40f80fb241 commit f558a73bafecee6d3cd45031e44e6e40f80fb241 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Feb 1 15:49:52 2016 -0800 Don't add DT_NEEDED for unmatched symbol Don't add DT_NEEDED if a symbol from a library loaded via DT_NEEDED doesn't match the symbol referenced by regular object. Backport from master bfd/ PR ld/19553 * elflink.c (elf_link_add_object_symbols): Don't add DT_NEEDED if a symbol from a library loaded via DT_NEEDED doesn't match the symbol referenced by regular object. ld/testsuite/ PR ld/19553 * testsuite/ld-elf/indirect.exp: Run tests for PR ld/19553. * testsuite/ld-elf/pr19553.map: New file. * testsuite/ld-elf/pr19553.map: Likewise. * testsuite/ld-elf/pr19553a.c: Likewise. * testsuite/ld-elf/pr19553b.c: Likewise. * testsuite/ld-elf/pr19553b.out: Likewise. * testsuite/ld-elf/pr19553c.c: Likewise. * testsuite/ld-elf/pr19553c.out: Likewise. * testsuite/ld-elf/pr19553d.c: Likewise. * testsuite/ld-elf/pr19553d.out: Likewise. Fixed. |