relocation R_X86_64_PC32 against `OPENSSL_cpuid_setup' link failure

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

relocation R_X86_64_PC32 against `OPENSSL_cpuid_setup' link failure

Tom Carroll
Hey all -

I am having some troubling creating .so when linking against openssl
0.9.8.  I do not encounter the problem when linking against openssl
0.9.7g.  The error appears to be specific to x86_64.  The system is a
EMT64 processor.

As an example, when linking against a stub that calls
SSL_library_init(), I receive the following:

ld -soname libtest.so -shared -o libtest.so test.o
-L/usr/src/1.3.33/openssl-0.9.8 --whole-archive -lssl -lcrypto
-no-whole-archive
ld: /usr/src/1.3.33/openssl-0.9.8/libcrypto.a(x86_64cpuid.o): relocation
R_X86_64_PC32 against `OPENSSL_cpuid_setup' can not be used when making
a shared object; recompile with -fPIC
ld: final link failed: Bad value

The openssl was config'd as no-shared no-threads -fPIC -DPIC.

I am certain that x86_64cpuid.o is compiled with -fPIC. An exert of the
build and output of file follows.

/usr/bin/perl x86_64cpuid.pl x86_64cpuid.s
gcc -I. -I.. -I../include -DDSO_DLFCN -DHAVE_DLFCN_H -fPIC -DPIC -m64
-DL_ENDIAN -DTERMIO -O3 -Wall -DMD32_REG_T=int -DMD5_ASM -c -I. -I..
-I../include -DDSO_DLFCN -DHAVE_DLFCN_H -fPIC -DPIC -m64 -DL_ENDIAN
-DTERMIO -O3 -Wall -DMD32_REG_T=int -DMD5_ASM -fPIC  -o x86_64cpuid.o
x86_64cpuid.s

file /usr/src/1.3.33/openssl-0.9.8/crypto/x86_64cpuid.o
/usr/src/1.3.33/openssl-0.9.8/crypto/x86_64cpuid.o: ELF 64-bit LSB
relocatable, AMD x86-64, version 1 (SYSV), not stripped.

The stable and the snapshots result in the same.

The specifics of my environment are:

Intel Xeon 2.8 (EMT64 processor)

uname -a
Linux linux 2.6.11.4-21.7-smp #1 SMP Thu Jun 2 14:23:14 UTC 2005 x86_64
x86_64 x86_64 GNU/Linux

gcc --version
gcc (GCC) 3.3.5 20050117 (prerelease) (SUSE Linux)

The old binutils are 2.15.94.0.2.2.  When I experienced problems, I
updated to   When I experienced problems, I updated to   When I
experienced problems, I updated to 2.16.1 (I made sure gcc was calling
the new binutils).  Both result in failure.

Any help is greatly appreciated.

TIA

- Tom
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: relocation R_X86_64_PC32 against `OPENSSL_cpuid_setup' link failure

Andy Polyakov
> ld -soname libtest.so -shared -o libtest.so test.o
> -L/usr/src/1.3.33/openssl-0.9.8 --whole-archive -lssl -lcrypto
> -no-whole-archive

First of all I'd recommend to use gcc -shared even to link shared
objects. Not that this would remedy the "R_X86_64_PC32 is no good for
shared object," it's just that using gcc is more fool-proof, as it will
also link in run-time environment initialization code [which might be
required]. In order to pass linker specific options use -Wl prefix, e.g.
you'd have to replace -soname libtest.so with -Wl,-soname,libtest.so in
gcc command line.

> ld: /usr/src/1.3.33/openssl-0.9.8/libcrypto.a(x86_64cpuid.o): relocation
> R_X86_64_PC32 against `OPENSSL_cpuid_setup' can not be used when making
> a shared object; recompile with -fPIC
> ld: final link failed: Bad value
>
> The openssl was config'd as no-shared no-threads -fPIC -DPIC.

If you can confirm that './config shared' works, then adding
-Wl,-Bsymbolic to your command line should do the trick. A.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]