Bug #29791 relocation R_X86_64_32 against `a local symbol'
Submitted: 13 Jul 2007 16:57 Modified: 5 Aug 2010 10:57
Reporter: Johan Andersson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:5.* OS:Linux (x86_64)
Assigned to: Magnus Blåudd CPU Architecture:Any

[13 Jul 2007 16:57] Johan Andersson
Description:
Related to:
http://bugs.mysql.com/bug.php?id=18091

gcc -shared
-nostdlib /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/crtbeginS.o  .libs/NdbBlob.o .libs/Ndb.o .libs/NdbIndexScanOperation.o .libs/NdbRecAttr.o .libs/NdbScanOperation.o .libs/NdbClusterConnection.o .libs/NdbIndexOperation.o .libs/NdbOperation.o .libs/NdbScanFilter.o .libs/NdbTransaction.o .libs/NdbjUtility.o  -Wl,--rpath -Wl,/usr/local/mysql/lib -Wl,--rpath -Wl,/usr/local/mysql/lib -L/usr/local/mysql/lib /usr/local/mysql/lib/libndbclient.so -lmystrings -lmysqlclient -lmysqlclient_r -lmysys -lstdc++ -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../.. -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/crtendS.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../lib64/crtn.o  -mtune=nocona -Wl,-soname -Wl,libndbj.so.0 -o .libs/libndbj.so.0.0.0
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/local/mysql/lib/libmystrings.a(my_vsnprintf.o): 

relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

How to repeat:
1) take a std mysql build from the webiste (5.0, 5.1) for X86_64, linux
2) link against mystrings using libtool. 

you will get:

relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

Suggested fix:
compile with -fPIC!!!
[13 Jul 2007 17:35] Johan Andersson
When I recompiled like this then I could link with relocation problem:

 CFLAGS="-march=opteron -g -O3 -fPIC" CXXFLAGS="-fPIC -march=opteron -g -O3" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-plugins=max --with-embedded-server --enable-local-infile --with-pic --with-ndb-ccflags="-fPIC"
[8 Aug 2007 20:58] MySQL Verification Team
Thank you for the bug report.
[4 Oct 2007 23:40] Monty Taylor
I can confirm this is still a problem as of 5.1.22. Johan's workaround is also still a workaround. This will be a problem for anyone trying to use NDB API on 64-bit linux systems.
[2 Nov 2007 22:52] John David Duncan
If you apply to following patch to storage/ndb/src/Makefile.am and then build mysql (run BUILD/autorun.sh , configure, and then make), you will get a library called libndbhelper.so which provides the missing parts from mysys and mystrings.   

You should then be able to link any NDB API application with "-lndbclient -lmysqlclient -lndbhelper" 

I have not tested this on 64-bit linux or with the mgmapi, but maybe it has some promise for solving the problem.

*** mysql-5.1.22-rc/storage/ndb/src/Makefile.am	2007-09-24 03:29:40.000000000 -0700
--- mysql-5.1.22-ndh2/storage/ndb/src/Makefile.am	2007-11-02 15:25:34.000000000 -0700
***************
*** 17,23 ****
  
  include $(top_srcdir)/storage/ndb/config/common.mk.am
  
! ndblib_LTLIBRARIES = libndbclient.la
  
  libndbclient_la_SOURCES =
  
--- 17,23 ----
  
  include $(top_srcdir)/storage/ndb/config/common.mk.am
  
! ndblib_LTLIBRARIES = libndbclient.la libndbhelper.la
  
  libndbclient_la_SOURCES =
  
***************
*** 34,39 ****
--- 34,58 ----
                common/portlib/libportlib.la      \
                common/util/libgeneral.la 
  
+ libndbhelper_la_CPPFLAGS = \
+ 	-I$(top_srcdir)/include \
+ 	-I$(top_srcdir)/mysys
+ 
+ libndbhelper_la_SOURCES = \
+        $(top_srcdir)/mysys/base64.c
+ 
+ libndbhelper_la_LIBADD = \       
+        $(top_srcdir)/mysys/errors.o \
+        $(top_srcdir)/mysys/my_lib.o \
+        $(top_srcdir)/mysys/my_gethostbyname.o \
+        $(top_srcdir)/mysys/my_thr_init.o \
+        $(top_srcdir)/mysys/my_static.o \
+        $(top_srcdir)/mysys/my_messnc.o \
+        $(top_srcdir)/mysys/my_error.o \
+        $(top_srcdir)/mysys/my_pthread.o \
+        $(top_srcdir)/mysys/my_getwd.o \
+        $(top_srcdir)/strings/decimal.o
+ 
  windoze-dsp: libndbclient.dsp
  
  libndbclient.dsp: Makefile \
[3 Nov 2007 7:31] John David Duncan
2nd version of ndbhelper patch

Attachment: ndbhelper.patch (, text), 3.23 KiB.

[3 Nov 2007 7:32] John David Duncan
Improved version of patch, now attached to bug report as a file.
[3 Nov 2007 7:35] John David Duncan
Apply with: patch -b -p1 < ndbhelper.patch
[3 Nov 2007 21:32] Monty Taylor
Well, first of all I'd like to say that I successfully worked with JD's patch and it worked as advertised. Removed the need to mysys and mystrings while compiling and also the need for extra fPIC flags. 

I would love it if we could do this with no extra libs, but I think that we will get the multiply defined symbols error if we add them directly to libndbclient. What if we added them to libmysqlclient? (I know - there's probably some reason not to)
[5 Nov 2007 18:30] John David Duncan
The patch can be smaller:
  my_lib.c is not needed.
  my_gethostbyname.c is not needed.
Both of these are also in mysqlclient.
[7 Nov 2007 18:05] John David Duncan
"one library" patch -- bumps libndbclient major version # up to 4 -- apply with patch -p1

Attachment: ndbapi4.patch (, text), 3.70 KiB.

[7 Nov 2007 18:06] Monty Taylor
Does this work with mysqld too? It doesn't conflict with linking against libmysqlclient?
[7 Nov 2007 18:17] John David Duncan
So far, testing on only one platform (Mac OS X 10.5 intel 32-bit), it works OK.
[14 Nov 2007 22:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37795

ChangeSet@1.2577, 2007-11-14 14:30:19-08:00, mtaylor@solace.(none) +4 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol'
  
  Applied JD's patch to tree. It works for me.
[14 Nov 2007 23:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37796

ChangeSet@1.2577, 2007-11-14 15:03:21-08:00, mtaylor@solace.(none) +4 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol'
  
  Applied JD's patch to tree. It works for me. 
  Changed libhelper.la to libndbhelper.la to prevent accidental namespace collision.
[14 Nov 2007 23:20] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37797

ChangeSet@1.2577, 2007-11-14 15:20:32-08:00, mtaylor@solace.(none) +4 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol'
  
  Added libtool helper lib to prevent link failures on amd64. The non-installed 
  libtool convenience lib removes the need to compile libmysys and libmystrings with
  -fPIC on amd64.
[27 Dec 2007 17:21] Monty Taylor
Turns out this affects more than just libndbclient, so the libndbclient fix will not be sufficient. 

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=457915

libmysqld is also affected.
[7 Feb 2008 16:36] Monty Taylor
This is broken on solaris as well. 

Voting again for building them as honest shared libs...
[23 Apr 2008 4:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45857

ChangeSet@1.2579, 2008-04-22 21:27:27-07:00, mtaylor@solace.(none) +32 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[23 Apr 2008 6:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45864

ChangeSet@1.2579, 2008-04-22 23:34:56-07:00, mtaylor@solace.(none) +39 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[23 Apr 2008 18:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45909

ChangeSet@1.2579, 2008-04-23 11:23:11-07:00, mtaylor@solace.(none) +39 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[23 Apr 2008 20:04] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45912

ChangeSet@1.2579, 2008-04-23 13:04:31-07:00, mtaylor@solace.(none) +44 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[23 Apr 2008 21:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45921

ChangeSet@1.2579, 2008-04-23 14:02:59-07:00, mtaylor@solace.(none) +42 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[23 Apr 2008 21:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45922

ChangeSet@1.2579, 2008-04-23 14:16:56-07:00, mtaylor@solace.(none) +44 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[24 Apr 2008 0:03] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45927

ChangeSet@1.2579, 2008-04-23 17:03:20-07:00, mtaylor@solace.(none) +44 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. The will no longer be installed, and all of the necessary symbols 
  from them are added directly to libndbclient et al. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[25 Apr 2008 2:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45980

ChangeSet@1.2579, 2008-04-24 19:01:31-07:00, mtaylor@solace.(none) +44 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. All of the necessary symbols from them are added directly to 
  libndbclient et al. Additionally, we still build a static libmysys.a, libdbug.a 
  and libmystrings.a, using the helper libs as well. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[25 Apr 2008 6:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/45988

ChangeSet@1.2579, 2008-04-24 23:32:23-07:00, mtaylor@solace.(none) +45 -0
  BUG#29791 relocation R_X86_64_32 against `a local symbol' 
  
  Changed libmysys, libmystrings and libdbug from normal libs to noinst libtool 
  helper libs. All of the necessary symbols from them are added directly to 
  libndbclient et al. Additionally, we still build a static libmysys.a, libdbug.a 
  and libmystrings.a, using the helper libs as well. The upside here is that 
  NDB API programs now only need to link against -lndbclient.
[25 Apr 2008 17:13] Bugs System
Pushed into 5.1.23-ndb-6.4.0
[25 Apr 2008 17:14] Bugs System
Pushed into 5.1.24-ndb-6.3.13
[25 Apr 2008 17:26] Bugs System
Pushed into 5.1.24-ndb-6.2.14
[25 Apr 2008 19:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/46045

ChangeSet@1.2580, 2008-04-25 12:26:11-07:00, mtaylor@solace.(none) +2 -0
  Bug #29791 relocation R_X86_64_32 against `a local symbol' 
  
  Fixed an automake dependency issue that shows up during make -j builds.
[25 Apr 2008 19:38] Bugs System
Pushed into 5.1.23-ndb-6.4.0
[25 Apr 2008 19:39] Bugs System
Pushed into 5.1.24-ndb-6.3.13
[26 Apr 2008 5:42] Bugs System
Pushed into 5.1.24-ndb-6.2.14
[20 May 2008 7:57] Jon Stephens
Documented in the 5.1.24-ndb-6.2.16 and 5.1.24-ndb-6.3.14 changelogs as follows:

        Changed libmysys, libmystrings, and libdbug from normal libs to noinst
        libtool helper libraries. They are no longer installed as separate
        libraries; instead, all necessary symbols from these are added directly
        to libndbclient . This means that NDB API programs now only need to link
        against -lndbclient.
[12 Dec 2008 23:26] Bugs System
Pushed into 6.0.6-alpha  (revid:sp1r-mtaylor@solace.(none)-20080425192611-04805) (version source revid:jonas@mysql.com-20080808094047-4e1yiarqa2t3opg3) (pib:5)
[2 Jun 2010 11:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/109948
[4 Jun 2010 10:03] Magnus Blåudd
Pushed to next-mr-bugfixing
[4 Jun 2010 12:56] Magnus Blåudd
Found one problem in the patch, libmysqld/Makefile.am should not reference the libtool library but rather rather the lib in .libs/ due to homegrown library creation loop.
[4 Jun 2010 13:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/110239
[15 Jun 2010 8:34] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615080558-cw01bzdqr1bdmmec) (version source revid:alik@sun.com-20100615080431-gu5icn0anrt47dsx) (pib:16)
[4 Aug 2010 8:09] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:alik@sun.com-20100615080431-gu5icn0anrt47dsx) (merge vers: 5.6.99-m4) (pib:18)
[4 Aug 2010 8:24] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:alik@sun.com-20100615080431-gu5icn0anrt47dsx) (merge vers: 5.6.99-m4) (pib:18)
[5 Aug 2010 10:57] Jon Stephens
Documented in the 5.6.0 and 6.0.6 changelogs as follows:

        To forestall the occurrence of possible relocation errors in 
        the future, libmysys, libmystrings, and libdbug have been 
        changed from normal libraries to "noinst" libtool helper 
        libraries, and are no longer installed as separate libraries.

Closed.