Bug 19698 - [2.26 Regression] mysql qt4 driver plugin not able to open libmysqlclient.so
Summary: [2.26 Regression] mysql qt4 driver plugin not able to open libmysqlclient.so
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.27
Assignee: H.J. Lu
URL:
Keywords:
: 19724 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-20 17:05 UTC by dura
Modified: 2016-02-26 13:40 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
linker input files for libqsqlmysql.so (6.55 MB, application/x-xz)
2016-02-21 11:37 UTC, dura
Details
linker input files for libmysqlclient.so (3.42 MB, application/x-xz)
2016-02-22 23:51 UTC, dura
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dura 2016-02-20 17:05:29 UTC
When starting akonadiserver, I got this message:
akonadiserver: relocation error: /usr/qt4/plugins/sqldrivers/libqsqlmysql.so: symbol mysql_real_connect, version libmysqlclient_16 not defined in file libmysqlclient.so.18 with link time reference

When recompiling mariadb-10.1.11 with binutils-2.25.1, the problem disappears.

A git bisect shows that https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=422f11824b3abf6c71042e2ee3aed572f250fc89 is the first bad commit.

binutils-2.26 with this commit reverted does not exhibit the problem.
Comment 1 H.J. Lu 2016-02-20 17:39:23 UTC
Please try users/hjl/pr19553/binutils-2_26-branch branch.
Comment 2 dura 2016-02-20 19:17:45 UTC
The problem stills there or I made a mistake with git (my knowledge of git is quite limited).

I used git like this:
git clone git://sourceware.org/git/binutils-gdb.git
git checkout users/hjl/pr19553/binutils-2_26-branch

and building the same way like when I was bisecting.
Comment 3 H.J. Lu 2016-02-20 22:31:06 UTC
Please provide all linker input files and command line options used to
build libqsqlmysql.so.
Comment 4 dura 2016-02-20 22:51:18 UTC
(In reply to H.J. Lu from comment #3)
> Please provide all linker input files and command line options used to
> build libqsqlmysql.so.

This is the command line that build libqsqlmysql.so:
g++ -Wl,-rpath-link,/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -Wl,-O1 -Wl,-rpath,/usr/qt4/lib -Wl,-rpath,/usr/qt4/lib -shared -o libqsqlmysql.so .obj/release-shared/main.o .obj/release-shared/qsql_mysql.o .obj/release-shared/moc_qsql_mysql.o   -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -L/usr/lib -lmysqlclient -lz -lm -ldl -lssl -lcrypto -lQtSql -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -lQtCore -lpthread

Can you tell me what should I do for "provide all linker input files"?

For bisecting, I rebuild binutils and mariadb, not QT.
Comment 5 H.J. Lu 2016-02-20 22:59:07 UTC
(In reply to dura from comment #4)
> (In reply to H.J. Lu from comment #3)
> > Please provide all linker input files and command line options used to
> > build libqsqlmysql.so.
> 
> This is the command line that build libqsqlmysql.so:
> g++
> -Wl,-rpath-link,/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-
> opensource-src-4.8.7/lib -Wl,-O1 -Wl,-rpath,/usr/qt4/lib
> -Wl,-rpath,/usr/qt4/lib -shared -o libqsqlmysql.so
> .obj/release-shared/main.o .obj/release-shared/qsql_mysql.o
> .obj/release-shared/moc_qsql_mysql.o  
> -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-
> 4.8.7/lib -L/usr/lib -lmysqlclient -lz -lm -ldl -lssl -lcrypto -lQtSql
> -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-
> 4.8.7/lib -lQtCore -lpthread
>
> Can you tell me what should I do for "provide all linker input files"?

These aren't linker command line options.  You should add "-v" to show
the command line options passed to linker.  I need all files passed to
linker as inputs, including .o, .a and .so files.  You can verify that
by putting all them in a directory and passing to ld:

# ld ...........................

with the same order shown by "g++ -v".
Comment 6 dura 2016-02-21 11:37:24 UTC
Created attachment 9022 [details]
linker input files for libqsqlmysql.so
Comment 7 dura 2016-02-21 11:42:17 UTC
This is what adding -v to g++ command line give me:
g++ -v -Wl,-rpath-link,/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -Wl,-O1 -Wl,-rpath,/usr/qt4/lib -Wl,-rpath,/usr/qt4/lib -shared -o libqsqlmysql.so .obj/release-shared/main.o .obj/release-shared/qsql_mysql.o .obj/release-shared/moc_qsql_mysql.o   -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -L/usr/lib -lmysqlclient -lz -lm -ldl -lssl -lcrypto -lQtSql -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -lQtCore -lpthread  
Reading specs from /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --disable-static --disable-multilib --with-native-system-header-dir=/usr/include --with-local-prefix=/usr/local --prefix=/usr --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-cloog --enable-cloog-backend=isl --with-system-zlib
Thread model: posix
gcc version 5.3.0 (GCC) 
COMPILER_PATH=/usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/:/usr/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/:/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-shared' '-o' 'libqsqlmysql.so' '-L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib' '-L/usr/lib' '-L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib' '-shared-libgcc' '-mtune=nehalem' '-march=nehalem'
 /usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/collect2 -plugin /usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccIMdc7u.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -shared -o libqsqlmysql.so /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/crti.o /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/crtbeginS.o -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -L/usr/lib -L/bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -L/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0 -L/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../.. -rpath-link /bsources/qt-everywhere-opensource-src-4.8.7/qt-everywhere-opensource-src-4.8.7/lib -O1 -rpath /usr/qt4/lib -rpath /usr/qt4/lib .obj/release-shared/main.o .obj/release-shared/qsql_mysql.o .obj/release-shared/moc_qsql_mysql.o -lmysqlclient -lz -ldl -lssl -lcrypto -lQtSql -lQtCore -lpthread -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/crtendS.o /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/crtn.o

I used this command to test the contents of the archive:
ld -nostdlib -o libqsqlmysql.so crti.o crtbeginS.o .obj/release-shared/main.o .obj/release-shared/qsql_mysql.o .obj/release-shared/moc_qsql_mysql.o -L. -lmysqlclient -lz -ldl -lssl -lcrypto -lQtSql -lQtCore -lpthread -lstdc++ -lm -lgcc_s -lc -lgcc_s -lgthread -lglib-2 -lrt -lpcre crtendS.o crtn.o -shared
Comment 8 H.J. Lu 2016-02-22 18:53:31 UTC
How was libmysqlclient.so built? I saw:

    78: 00000000000296d0     0 FUNC    GLOBAL DEFAULT   11 mysql_real_connect@@libmysqlclient_16
   229: 00000000000296d0  3522 FUNC    GLOBAL DEFAULT   11 mysql_real_connect@@libmysqlclient_18
   331: 000000000002b7d0   187 FUNC    GLOBAL DEFAULT   11 

There can't be 2 default version for mysql_real_connect, one is
mysql_real_connect@@libmysqlclient_16 and the other is

mysql_real_connect_cont@@libmysqlclient_18

My libmysqlclient.so has

   538: 000000000002d020     0 FUNC    GLOBAL DEFAULT   12 mysql_real_connect@libmysqlclient_16
   539: 000000000002d020  4406 FUNC    GLOBAL DEFAULT   12 mysql_real_connect@@libmysqlclient_18
   574: 000000000002f830   216 FUNC    GLOBAL DEFAULT   12 

mysql_real_connect@@libmysqlclient_18 is default and
mysql_real_connect@libmysqlclient_16 isn't.

The difference is @@libmysqlclient_16 vs @libmysqlclient_16.
Comment 9 H.J. Lu 2016-02-22 19:06:34 UTC
Please double check that libmysqlclient.so was built using a linker with
PR 19073 fixed.
Comment 10 dura 2016-02-22 20:33:14 UTC
libmysqlclient.so in the tarball was built with command line in comment #7 and binutils 2.26 commit 422f11824b3abf6c71042e2ee3aed572f250fc89 reversed, so as a consequence, without PR 19073 which is a correction for this commit.

All my produced libmysqlclient.so with binutils 2.26 show mysql_real_connect@@libmysqlclient_16 and mysql_real_connect_cont@@libmysqlclient_18 with or without 422f11824b3abf6c71042e2ee3aed572f250fc89 reversed as a result of "readelf --symbols libmysqlclient.so"
Comment 11 H.J. Lu 2016-02-22 20:37:21 UTC
(In reply to dura from comment #10)
> libmysqlclient.so in the tarball was built with command line in comment #7
> and binutils 2.26 commit 422f11824b3abf6c71042e2ee3aed572f250fc89 reversed,
> so as a consequence, without PR 19073 which is a correction for this commit.
> 
> All my produced libmysqlclient.so with binutils 2.26 show
> mysql_real_connect@@libmysqlclient_16 and
> mysql_real_connect_cont@@libmysqlclient_18 with or without
> 422f11824b3abf6c71042e2ee3aed572f250fc89 reversed as a result of "readelf
> --symbols libmysqlclient.so"

Please provide all linker input files for creating libmysqlclient.so.
Comment 12 H.J. Lu 2016-02-22 22:26:03 UTC
(In reply to H.J. Lu from comment #11)
> (In reply to dura from comment #10)
> > libmysqlclient.so in the tarball was built with command line in comment #7
> > and binutils 2.26 commit 422f11824b3abf6c71042e2ee3aed572f250fc89 reversed,
> > so as a consequence, without PR 19073 which is a correction for this commit.
> > 
> > All my produced libmysqlclient.so with binutils 2.26 show
> > mysql_real_connect@@libmysqlclient_16 and
> > mysql_real_connect_cont@@libmysqlclient_18 with or without
> > 422f11824b3abf6c71042e2ee3aed572f250fc89 reversed as a result of "readelf
> > --symbols libmysqlclient.so"
> 
> Please provide all linker input files for creating libmysqlclient.so.

I also need linker command line options for creating libmysqlclient.so.
Comment 13 dura 2016-02-22 23:51:47 UTC
Created attachment 9027 [details]
linker input files for libmysqlclient.so
Comment 14 dura 2016-02-22 23:53:38 UTC
This is the linker command line as shown by g++ -v:
/usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/collect2 -plugin /usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccYF735e.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -shared -o libmysqlclient.so.18.0.0 -s -s /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/crti.o /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/crtbeginS.o -L/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0 -L/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../.. -z relro -z now --no-undefined --no-undefined /bsources2/mariadb-10.1.11/build/libmysql/libmysql_versions.ld -soname libmysqlclient.so.18 CMakeFiles/libmysql.dir/libmysql_exports_file.cc.o -lpthread libclientlib.a ../dbug/libdbug.a ../strings/libstrings.a ../vio/libvio.a ../mysys/libmysys.a ../mysys_ssl/libmysys_ssl.a -lz -lssl -lcrypto -ldl -ldl ../dbug/libdbug.a ../mysys/libmysys.a ../mysys_ssl/libmysys_ssl.a -lz ../strings/libstrings.a -lssl -lcrypto -ldl -lpthread -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/crtendS.o /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../lib/crtn.o

I used strace to find out all files used by the linker.
Comment 15 H.J. Lu 2016-02-23 01:01:40 UTC
A simple testcase:

[hjl@gnu-6 pr19698]$ cat foo.c
void
foo ()
{
}
[hjl@gnu-6 pr19698]$ cat foo.v
"foo@VERS.1" = foo;

VERSION {
VERS.2 {
  global:
    foo;
};

VERS.1 {
};
}
[hjl@gnu-6 pr19698]$ make
readelf --dyn-syms libfoo.so | grep foo
     2: 00000000000002b4     0 FUNC    GLOBAL DEFAULT    6 foo@@VERS.1
     5: 00000000000002b4     7 FUNC    GLOBAL DEFAULT    6 foo@@VERS.2
[hjl@gnu-6 pr19698]$
Comment 16 H.J. Lu 2016-02-23 01:02:32 UTC
[hjl@gnu-6 pr19698]$ make libfoo.so
gcc    -c -o foo.o foo.c
./ld -o libfoo.so -shared foo.v foo.o
[hjl@gnu-6 pr19698]$
Comment 18 dura 2016-02-24 23:00:56 UTC
I can confirm that building mariadb with binutils-2.26, with your patch and without 422f11824b3abf6c71042e2ee3aed572f250fc89422f11824b3abf6c71042e2ee3aed572f250fc89 reversed produce a libmysqlclient.so that does not show double default mysql_real_connect and is usable by akonadiserver.
Comment 19 Sourceware Commits 2016-02-24 23:15:17 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0f550b3df1d4ae31d12505cf93981313c9c6dd25

commit 0f550b3df1d4ae31d12505cf93981313c9c6dd25
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Feb 24 15:13:35 2016 -0800

    Update symbol version for symbol from linker script
    
    We need to update symbol version for symbols from linker script.
    
    bfd/
    
    	PR ld/19698
    	* elflink.c (bfd_elf_record_link_assignment): Set versioned if
    	symbol version is unknown.
    
    ld/
    
    	PR ld/19698
    	* testsuite/ld-elf/pr19698.d: New file.
    	* testsuite/ld-elf/pr19698.s: Likewise.
    	* testsuite/ld-elf/pr19698.t: Likewise.
Comment 20 Gleb Fotengauer-Malinovskiy 2016-02-25 02:41:37 UTC
*** Bug 19724 has been marked as a duplicate of this bug. ***
Comment 21 Sourceware Commits 2016-02-26 13:40:00 UTC
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=544ddf9322b1b83982e5cb84a54d084ee7e718ea

commit 544ddf9322b1b83982e5cb84a54d084ee7e718ea
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Feb 24 15:13:35 2016 -0800

    Update symbol version for symbol from linker script
    
    We need to update symbol version for symbols from linker script.
    
    Backport from master
    
    bfd/
    
    	PR ld/19698
    	* elflink.c (bfd_elf_record_link_assignment): Set versioned if
    	symbol version is unknown.
    
    ld/
    
    	PR ld/19698
    	* testsuite/ld-elf/pr19698.d: New file.
    	* testsuite/ld-elf/pr19698.s: Likewise.
    	* testsuite/ld-elf/pr19698.t: Likewise.
Comment 22 H.J. Lu 2016-02-26 13:40:24 UTC
Fixed for trunk and 2.26 branch.