Optware / Optware-ng

279 stars 52 forks source link

perl error: unresolved symbol 'Perl_eval_pv' #29

Closed kostea67 closed 8 years ago

kostea67 commented 8 years ago

Hi, i have a problem running perl scripts (e.g. mrtg), i'm getting this error about unresolved symbol: "/tmp/mnt/optware/optware-ng/bin/perl5.20.1: can't resolve symbol 'Perl_eval_pv' " I have tried setting variable: export PERL5LIB=/opt/lib/perl5/5.20.1 but no success Any idea? The router si RT-N66U, firmware 378.56_2, perl v5.20.1 installed with ipkg. about perl: perl -V Summary of my perl5 (revision 5 version 20 subversion 1) configuration:

Platform: osname=linux, osvers=2.6.22.19, archname=mips-linux uname='linux unknown 2.6.22.19 #8 tue jul 8 17:08:51 cest 2014 mips gnulinux ' config_args='-Dcc=gcc -Dprefix=/opt -Duseshrplib -Dd_dlopen -de -Aldflags=-Wl,-rpath,/opt/lib -lpthread' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='/home/alex/optware/buildroot-mipsel-ng/toolchain/buildroot-mipsel-linux-2.6.36-uclibc-ng-5.2.0/bin/mipsel-buildroot-linux-uclibc-gcc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -pipe -I/home/alex/optware/buildroot-mipsel-ng/staging/opt/include ', optimize='-O2', cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector' ccversion='', gccversion='5.2.0', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='/home/alex/optware/buildroot-mipsel-ng/toolchain/buildroot-mipsel-linux-2.6.36-uclibc-ng-5.2.0/bin/mipsel-buildroot-linux-uclibc-ld', ldflags =' -Wl,-rpath,/opt/lib -lpthread -fstack-protector' libpth=/opt/lib /opt/lib/gcc/mipsel-buildroot-linux-uclibc/5.2.0/include-fixed /lib /usr/lib libs=-lnsl -lgdbm -ldb-5.3 -ldl -lm -lcrypt -lutil -lc -lgdbm_compat -lpthread -ldb-5.3 -lgdbm -lgdbm_compat perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/opt/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/lib/perl5/5.20.1/mips-linux/CORE' cccdlflags='-fPIC', lddlflags='-shared -O2 -fstack-protector'

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_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO
USE_PERL_ATOF
Built under linux Compiled at Nov 6 2015 00:57:47 @INC: /opt/lib/perl5/site_perl/5.20.1/mips-linux /opt/lib/perl5/site_perl/5.20.1 /opt/lib/perl5/5.20.1/mips-linux /opt/lib/perl5/5.20.1 .

alllexx88 commented 8 years ago

I can't reproduce this on my RT-N66U with tomatousb Shibby mod firmware:

root@unknown:/tmp/home/root# /opt/bin/mrtg
Usage: mrtg <config-file>

mrtg-2.17.2 - Multi Router Traffic Grapher

Copyright 1995-2006 by Tobias Oetiker
Licensed under the Gnu GPL.

If you want to know more about this tool, you might want
to read the docs. You can find everything on the
mrtg website:

http://oss.oetiker.ch/mrtg/

root@unknown:/tmp/home/root# /opt/bin/perl -V
Summary of my perl5 (revision 5 version 20 subversion 1) configuration:

  Platform:
    osname=linux, osvers=2.6.22.19, archname=mips-linux
    uname='linux unknown 2.6.22.19 #8 tue jul 8 17:08:51 cest 2014 mips gnulinux '
    config_args='-Dcc=gcc -Dprefix=/opt -Duseshrplib -Dd_dlopen -de -Aldflags=-Wl,-rpath,/opt/lib -lpthread'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/home/alex/optware/buildroot-mipsel-ng/toolchain/buildroot-mipsel-linux-2.6.36-uclibc-ng-5.2.0/bin/mipsel-buildroot-linux-uclibc-gcc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -pipe -I/home/alex/optware/buildroot-mipsel-ng/staging/opt/include ',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='5.2.0', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/home/alex/optware/buildroot-mipsel-ng/toolchain/buildroot-mipsel-linux-2.6.36-uclibc-ng-5.2.0/bin/mipsel-buildroot-linux-uclibc-ld', ldflags =' -Wl,-rpath,/opt/lib -lpthread -fstack-protector'
    libpth=/opt/lib /opt/lib/gcc/mipsel-buildroot-linux-uclibc/5.2.0/include-fixed /lib /usr/lib
    libs=-lnsl -lgdbm -ldb-5.3 -ldl -lm -lcrypt -lutil -lc -lgdbm_compat -lpthread -ldb-5.3 -lgdbm -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/opt/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/opt/lib/perl5/5.20.1/mips-linux/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -fstack-protector'

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_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
                        USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO
                        USE_PERL_ATOF
  Built under linux
  Compiled at Sep 12 2015 22:31:04
  @INC:
    /opt/lib/perl5/site_perl/5.20.1/mips-linux
    /opt/lib/perl5/site_perl/5.20.1
    /opt/lib/perl5/5.20.1/mips-linux
    /opt/lib/perl5/5.20.1
    .

Could you try a clean install of Optware-ng in case something went wrong in your setup?

On second thought, I see that Optware-ng is installed to /tmp/mnt/optware/optware-ng. Is /tmp/mnt/optware/optware-ng mounted on top of /opt? Unless it is, don't expect Optware-ng to work properly.

kostea67 commented 8 years ago

Thank you for your answer. Optware is the name of partition, is mounted corectly: admin@GWT:/# cd /opt admin@GWT:/tmp/mnt/optware/optware-ng# Simple perl scripts are working, but the error is still there if i'm trying to run some real-life scripts: mrtg whitout config is also working on my setup: admin@GWT:/tmp/mnt/optware/optware-ng# mrtg Usage: mrtg

mrtg-2.17.2 - Multi Router Traffic Grapher

Copyright 1995-2006 by Tobias Oetiker Licensed under the Gnu GPL.

If you want to know more about this tool, you might want to read the docs. You can find everything on the mrtg website:

http://oss.oetiker.ch/mrtg/

admin@GWT:/tmp/mnt/optware/optware-ng#

but with config i have the error:

admin@GWT:/tmp/mnt/optware/optware-ng# mrtg /opt/etc/mrtg.cfg /tmp/mnt/optware/optware-ng/bin/perl5.20.1: can't resolve symbol 'Perl_eval_pv' admin@GWT:/tmp/mnt/optware/optware-ng#

alllexx88 commented 8 years ago

Indeed, it happens to me too. 'Perl_eval_pv' symbol can be found in libperl.so:

root@unknown:/tmp/home/root# nm -g /opt/lib/perl5/5.20.1/mips-linux/CORE/libperl.so|grep Perl_eval_pv
00001f88 T Perl_eval_pv

For some reason, perl isn't linked with libperl.so:

root@unknown:/tmp/home/root# readelf -d /opt/bin/perl

Dynamic section at offset 0x1a0 contains 31 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.1]
 0x00000001 (NEEDED)                     Shared library: [libnsl.so.1]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.1]
 0x00000001 (NEEDED)                     Shared library: [libm.so.1]
 0x00000001 (NEEDED)                     Shared library: [libcrypt.so.1]
 0x00000001 (NEEDED)                     Shared library: [libutil.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.1]
 0x00000001 (NEEDED)                     Shared library: [ld-uClibc.so.1]
 0x0000000f (RPATH)                      Library rpath: [/opt/lib:/opt/lib/perl5/5.20.1/mips-linux/CORE]
 0x0000000c (INIT)                       0x40cc58
 0x0000000d (FINI)                       0x550f40
 0x00000004 (HASH)                       0x4002c0
 0x00000005 (STRTAB)                     0x4077d4
 0x00000006 (SYMTAB)                     0x402714
 0x0000000a (STRSZ)                      18988 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x70000016 (MIPS_RLD_MAP)               0x58d070
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x58d080
 0x70000001 (MIPS_RLD_VERSION)           1
 0x70000005 (MIPS_FLAGS)                 NOTPOT
 0x70000006 (MIPS_BASE_ADDRESS)          0x400000
 0x7000000a (MIPS_LOCAL_GOTNO)           1035
 0x70000011 (MIPS_SYMTABNO)              1292
 0x70000012 (MIPS_UNREFEXTNO)            30
 0x70000013 (MIPS_GOTSYM)                0x409
 0x6ffffffe (VERNEED)                    0x40cc18
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x40c200
 0x00000000 (NULL)                       0x0

and this is probably the cause of the issue. I'll try adding '-lperl' flag manually, I wonder why it's not passed by default.

alllexx88 commented 8 years ago

After further investigation, the problem is actually with IO module:

root@unknown:/opt/lib/perl5/5.20.1/mips-linux/CORE# perl
use IO;
Parameterless "use IO" deprecated at - line 1.
/opt/bin/perl5.20.1: can't resolve symbol 'Perl_eval_pv'

It was not linked with libperl.so (which is actually a static archive), thus 'Perl_eval_pv' symbol wasn't imported. I've written a patch that should fix it for all modules bundled with perl, this is actually a perl-cross issue. Building perl right now, stay tuned :-)

P.S. By manually building IO.so linked with libperl.so, I got mrtg to work:

root@unknown:/opt/lib/perl5/5.20.1/mips-linux/CORE# mrtg /opt/etc/mrtg.cfg
Use of uninitialized value $first in pattern match (m//) at /opt/bin/../lib/mrtg2/MRTG_lib.pm line 631.
Bareword "Errno::EINVAL" not allowed while "strict subs" in use at /opt/lib/perl5/5.20.1/mips-linux/IO/Socket.pm line 135.
Compilation failed in require at /opt/bin/../lib/mrtg2/SNMP_Session.pm line 598.
BEGIN failed--compilation aborted at /opt/bin/../lib/mrtg2/SNMP_Session.pm line 598.
Compilation failed in require at /opt/bin/../lib/mrtg2/SNMP_util.pm line 44.
BEGIN failed--compilation aborted at /opt/bin/../lib/mrtg2/SNMP_util.pm line 44.
Compilation failed in require at /opt/bin/../lib/mrtg2/MRTG_lib.pm line 662.

/opt/etc/mrtg.cfg is empty, so the output is correct, I think.

alllexx88 commented 8 years ago

I believe the issue is fixed and uploaded for mipsel in https://github.com/alllexx88/Optware-ng/commit/10d7ea47260d4bd155063a7feef2858affbb9e9c Other targets compiling atm.

kostea67 commented 8 years ago

I updated perl to ver. 5.20.1-2 and with a valid cfg i also got:

admin@GWT:/# /opt/bin/mrtg /opt/etc/mrtg/cpu.cfg Bareword "Errno::EINVAL" not allowed while "strict subs" in use at /opt/lib/perl5/5.20.1/mips-linux/IO/Socket.pm line 135. Compilation failed in require at /tmp/mnt/optware/optware-ng/bin/../lib/mrtg2/SNMP_Session.pm line 598. BEGIN failed--compilation aborted at /tmp/mnt/optware/optware-ng/bin/../lib/mrtg2/SNMP_Session.pm line 598. Compilation failed in require at /tmp/mnt/optware/optware-ng/bin/../lib/mrtg2/SNMP_util.pm line 44. BEGIN failed--compilation aborted at /tmp/mnt/optware/optware-ng/bin/../lib/mrtg2/SNMP_util.pm line 44. Compilation failed in require at /tmp/mnt/optware/optware-ng/bin/../lib/mrtg2/MRTG_lib.pm line 662.

alllexx88 commented 8 years ago
Bareword "Errno::EINVAL" not allowed while "strict subs" in use at /opt/lib/perl5/5.20.1/mips-linux/IO/Socket.pm line 135.

This looks similar to the following perl issue: https://rt.perl.org/Public/Bug/Display.html?id=123784 It was fixed upstream, and I applied this fix to Optware-ng: 6efaaee7828fefc0fc4b55088ace297578c43cf2 Please upgrade perl to 5.20.1-3 and test

kostea67 commented 8 years ago

Everything seems to work great now! Many thanks!!

alllexx88 commented 8 years ago

Great, glad it works, thanks for the feedback :-)