Bug #29791 relocation R_X86_64_32 against `a local symbol'
Submitted: 13 Jul 2007 18:57 Modified: 20 May 2008 9:57
Reporter: Johan Andersson
Status: Closed
Category:Server: Packaging Severity:S3 (Non-critical)
Version:5.* OS:Linux (x86_64)
Assigned to: Monty Taylor Target Version:
Triage: D2 (Serious)

[13 Jul 2007 18: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 19: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 22:58] Miguel Solorzano
Thank you for the bug report.
[5 Oct 2007 1: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 23: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 8:31] John David Duncan
2nd version of ndbhelper patch

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

[3 Nov 2007 8:32] John David Duncan
Improved version of patch, now attached to bug report as a file.
[3 Nov 2007 8:35] John David Duncan
Apply with: patch -b -p1 < ndbhelper.patch
[3 Nov 2007 22: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 19: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 19: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 19:06] Monty Taylor
Does this work with mysqld too? It doesn't conflict with linking against libmysqlclient?
[7 Nov 2007 19: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 23: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.
[15 Nov 2007 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/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.
[15 Nov 2007 0: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 18: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 17:36] Monty Taylor
This is broken on solaris as well. 

Voting again for building them as honest shared libs...
[23 Apr 2008 6: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 8: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 20: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 22: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 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/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 23: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 2: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 4: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 8: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 19:13] Bugs System
Pushed into 5.1.23-ndb-6.4.0
[25 Apr 2008 19:14] Bugs System
Pushed into 5.1.24-ndb-6.3.13
[25 Apr 2008 19:26] Bugs System
Pushed into 5.1.24-ndb-6.2.14
[25 Apr 2008 21: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 21:38] Bugs System
Pushed into 5.1.23-ndb-6.4.0
[25 Apr 2008 21:39] Bugs System
Pushed into 5.1.24-ndb-6.3.13
[26 Apr 2008 7:42] Bugs System
Pushed into 5.1.24-ndb-6.2.14
[20 May 2008 9: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.
[13 Dec 2008 0: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)