Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Relocation errors in Crypt::SSLeay in Solaris 10

by arielCo (Sexton)
on Mar 14, 2014 at 04:08 UTC ( #1078281=perlquestion: print w/ replies, xml ) Need Help??
arielCo has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed knowers of things Perl:

I'm get relocation errors when testing Crypt::SSLeay against OpenSSL 0.9.7 (the version bundled with SunOS 5.10). I've been using GCC in the past successfully, setting RPATH through LDDLFLAGS=-Wl.

Check it out:

cpan[1]> o conf $CPAN::Config options from /export/home/pprepago/.cpan/CPAN/MyConfig.p +m: ... make [/usr/sfw/bin/gmake] make_arg [] make_install_arg [] make_install_make_command [/usr/sfw/bin/gmake] makepl_arg [LDDLFLAGS="-m64 -G -Wl,-rpath,/usr/sfw/lib/64/ +"] mbuild_arg [] mbuild_install_arg [] ... cpan[2]> make Crypt::SSLeay ... /my_path_to/perl5/bin/perl /my_path_to/perl5/lib/perl5/site_perl/5.18. +0/ExtUtils/xsubpp -typemap /my_path_to/perl5/lib/perl5/5.18.0/ExtUti +ls/typemap -typemap typemap SSLeay.xs > SSLeay.xsc && mv SSLeay.xsc +SSLeay.c gcc -c -mcpu=v9 -m64 -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE +-D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -DVERSION=\"0.64\ +" -DXS_VERSION=\"0.64\" -fPIC "-I/my_path_to/perl5/lib/perl5/5.18.0/s +un4-solaris-64/CORE" SSLeay.c rm -f blib/arch/auto/Crypt/SSLeay/SSLeay.so LD_RUN_PATH="/usr/lib/sparcv9" gcc -m64 -G -Wl,-rpath,/usr/sfw/lib/64 +/ SSLeay.o -o blib/arch/auto/Crypt/SSLeay/SSLeay.so \ -lz \ ... /my_path_to/perl5/bin/perl -MExtUtils::Command::MM -e 'cp_nonempty' -- + SSLeay.bs blib/arch/auto/Crypt/SSLeay/SSLeay.bs 644 ... /usr/sfw/bin/gmake -- OK 'YAML' not installed, will not store persistent state cpan[3]> test Crypt::SSLeay ... PERL_DL_NONLAZY=1 /my_path_to/perl5/bin/perl "-MExtUtils::Command::MM" + "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness +(0, 'blib/lib', 'blib/arch')" t/*.t t/00-basic.t .... 1/12 # Failed test 'use Crypt::SSLeay;' # at t/00-basic.t line 6. # Tried to use 'Crypt::SSLeay'. # Error: Can't load '/export/home/pprepago/.cpan/build/Crypt-SSLe +ay-0.64-dCcYQu/blib/arch/auto/Crypt/SSLeay/SSLeay.so' for module Cryp +t::SSLeay: ld.so.1: perl: fatal: relocation error: file /export/home/ +pprepago/.cpan/build/Crypt-SSLeay-0.64-dCcYQu/blib/arch/auto/Crypt/SS +Leay/SSLeay.so: symbol SSL_alert_type_string_long: referenced symbol +not found at /my_path_to/perl5/lib/perl5/5.18.0/sun4-solaris-64/DynaL +oader.pm line 190.

Bummer. Let's check libssl.so for the 'missing' symbol and that SSLeay.so has the right RPATH:

$ file /usr/sfw/lib/64/libssl.so blib/arch/auto/Crypt/SSLeay/SSLeay.so /usr/sfw/lib/64/libssl.so: ELF 64-bit MSB dynamic lib SPARCV9 Ver +sion 1, dynamically linked, not stripped, no debugging information av +ailable blib/arch/auto/Crypt/SSLeay/SSLeay.so: ELF 64-bit MSB dynamic lib SPA +RCV9 Version 1, dynamically linked, not stripped, no debugging inform +ation available $ /usr/ccs/bin/elfdump Crypt-SSLeay-0.64-dCcYQu/blib/arch/auto/Crypt/S +SLeay/SSLeay.so | grep PATH [4] RUNPATH 0x6d7 /lib/64:/usr/lib/64: +/usr/sfw/lib/64:/usr/sfw/lib/64/ [5] RPATH 0x6d7 /lib/64:/usr/lib/64: +/usr/sfw/lib/64:/usr/sfw/lib/64/ $ /usr/ccs/bin/elfdump -s /usr/sfw/lib/64/libssl.so.0.9.7 | grep SSL_a +lert_type_string_long [37] 0x0000000000033370 0x000000000000005c FUNC GLOB D 0 . +text SSL_alert_type_string_long [1387] 0x0000000000033370 0x000000000000005c FUNC GLOB D 0 . +text SSL_alert_type_string_long
perl -V:
$ /my_path_to/perl5/bin/perl -V Summary of my perl5 (revision 5 version 18 subversion 0) configuration +: Platform: osname=solaris, osvers=2.10, archname=sun4-solaris-64 uname='sunos cfprepagop01 5.10 generic_148888-05 sun4v sparc sun4v + ' config_args='-des -Dprefix=/ -Duse64bitall -Duserelocatableinc -Di +nitialinstalllocation=/foo -Dmake=/usr/sfw/bin/gmake -Dcc=gcc -Doptim +ize=-O2 -Dcf_by=arielCo -Dcf_email=arielco@mycompany.com' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-mcpu=v9 -m64 -fno-strict-aliasing -pipe -D_LA +RGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV', optimize='-O2', cppflags='-mcpu=v9 -m64 -fno-strict-aliasing -pipe' ccversion='', gccversion='3.4.3 (csl-sol210-3_4-branch+sol_rpath)' +, gccosandvers='solaris2.10' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=87654321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -m64 -L/usr/lib/sparcv9 ' libpth=/usr/lib/sparcv9 /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/usr/lib/sparcv9/libc.so, so=so, useshrplib=false, libperl=li +bperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-fPIC', lddlflags=' -G -m64 -L/usr/lib/sparcv9' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_ +WRAP PERL_PRESERVE_IVUV PERL_SAWAMPERSAND PERL_USE_SAFE_PUTENV USE_64_BIT_ALL USE_64_BIT +_INT USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Built under solaris Compiled at Sep 9 2013 13:09:04 @INC: /my_path_to/perl5/lib/perl5/site_perl/5.18.0/sun4-solaris-64 /my_path_to/perl5/lib/perl5/site_perl/5.18.0 /my_path_to/perl5/lib/perl5/5.18.0/sun4-solaris-64 /my_path_to/perl5/lib/perl5/5.18.0 .
Other things I've tried:
  • Supplying LD_LIBRARY_PATH=/usr/sfw/lib/64 doesn't help. LD_LIBRARY_PATH_64 is unset. LD_PRELOAD_64=/usr/sfw/lib/64/libssl.so does work.
  • ldd -s Crypt-SSLeay-0.64-*/blib/arch/auto/Crypt/SSLeay/SSLeay.so doesn't even mention openssl.so. ldd -sr complains about several SSL_* symbols missing plus some other symbols like main and Perl_*.
  • It makes no difference to use /usr/sfw/lib/64 (symlink) or /usr/sfw/lib/sparcv9

Comment on Relocation errors in Crypt::SSLeay in Solaris 10
Select or Download Code
Re: Relocation errors in Crypt::SSLeay in Solaris 10
by hazylife (Monk) on Mar 14, 2014 at 10:30 UTC
    LD_PRELOAD_64=/usr/sfw/lib/64/libssl.so does work.
    Sounds like libssl.so is not being linked in, so you might need to add "-lssl -lcrypto" to the LDLOADLIBS line in the Makefile:
    LDLOADLIBS = -lz -L/usr/sfw/lib/64 -lssl -lcrypto

      That works - thanks a bunch. For anyone else reading, it's easy to pass this through 'o conf':

         o conf makepl_arg 'LIBS="-lz -L/usr/sfw/lib/64 -lssl -lcrypto"'

      Long story: turns out that -lssl -lcrypto are being left out of EXTRALIBS and LDLOADLIBS in the Makefile (no idea why - Makefile.PL comes with LIBS => [q{-lz -lssl -lcrypto -lssl32 -lssleay32 -leay32}]). So putting them in the Makefile and building again from the shell works too:

      EXTRALIBS = -lz -lssl -lcrypto LDLOADLIBS = -lz -lssl -lcrypto
        Makefile.PL comes with LIBS => q{-lz -lssl -lcrypto -lssl32 -lssleay32 -leay32})

        If those libraries are not located at the 'perl Makefile.PL' step, they don't get written in to the generated Makefile.
        It would seem that /usr/sfw/lib/64 is not being searched - for which another fix would be to change the quoted entry in the Makefile.PL to:
        LIBS => [q{-lz -L/usr/sfw/lib/64 -lssl -lcrypto -lssl32 -lssleay32 -le +ay32}])
        Passing it through 'o conf' is probably a better solution - in that it doesn't involve manual editing of any files.
        Yet another option would be to add /usr/sfw/lib/64 to the LIBRARY_PATH environment variable:
        export LIBRARY_PATH=$LIBRARY_PATH:/usr/sfw/lib/64
        Cheers,
        Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1078281]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-07-06 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (82 votes), past polls