Could not run any executable downloaded through opkg

Device: unknown with Intel Atom E3845 CPU
Architecture: i386_pentium4
OpenWRT version: 21.02.1, can't upgrade due to old software

I have installed "ntpd" and "file" packages through opkg with command "opkg install {packageName}" but when i trying to start it, bash returns "no such file or directory". Of course i googled it in every known variant (just in case). And the question is "What should i do to run it successfully?"

Here are some details of my research:
If i run with /lib/ld-linux.so.2 /sbin/ntdp it returns /sbin/ntpd: symbol lookup error: /sbin/ntpd: undefined symbol: __stime64
and with /usr/bin/file similar: /usr/bin/file: symbol lookup error: /usr/lib/liblzma.so.5: undefined symbol: pthread_create.

I would like to check which libs these programs want but ldd returns the same "no such file or directory".

If i run "file" on my Ubuntu machine and test these executables it will show the same info as for bash (that was also copied from i386 machine) but with different interpreter:

"file" returns:
guest@PC:~$ file ntpd
ntpd: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-i386.so.1, no section header
guest@PC:~$ file bash
bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 4.14.0, stripped

If i understand correctly, ld-musl and ld-linux are the same in some way. However i could not find any "musl" package but "musl-fts" (that i installed just in hope it will help).

I got more details about these problems with LD_DEBUG and here is the last part of each run with LD_DEBUG='all':

ntpd
      2330:	relocation processing: /sbin/ntpd
      2330:	symbol=BN_div;  lookup in file=/sbin/ntpd [0]
      2330:	symbol=BN_div;  lookup in file=/usr/lib/libcap.so.2 [0]
      2330:	symbol=BN_div;  lookup in file=/usr/lib/libcrypto.so.1.1 [0]
      2330:	binding file /sbin/ntpd [0] to /usr/lib/libcrypto.so.1.1 [0]: normal symbol `BN_div' [OPENSSL_1_1_0]
      2330:	symbol=sem_init;  lookup in file=/sbin/ntpd [0]
      2330:	symbol=sem_init;  lookup in file=/usr/lib/libcap.so.2 [0]
      2330:	symbol=sem_init;  lookup in file=/usr/lib/libcrypto.so.1.1 [0]
      2330:	symbol=sem_init;  lookup in file=/lib/libgcc_s.so.1 [0]
      2330:	symbol=sem_init;  lookup in file=/lib/libc.so [0]
      2330:	symbol=sem_init;  lookup in file=/lib/libdl.so.2 [0]
      2330:	symbol=sem_init;  lookup in file=/lib/libpthread.so.0 [0]
      2330:	binding file /sbin/ntpd [0] to /lib/libpthread.so.0 [0]: normal symbol `sem_init'
      2330:	symbol=EVP_DigestInit_ex;  lookup in file=/sbin/ntpd [0]
      2330:	symbol=EVP_DigestInit_ex;  lookup in file=/usr/lib/libcap.so.2 [0]
      2330:	symbol=EVP_DigestInit_ex;  lookup in file=/usr/lib/libcrypto.so.1.1 [0]
      2330:	binding file /sbin/ntpd [0] to /usr/lib/libcrypto.so.1.1 [0]: normal symbol `EVP_DigestInit_ex' [OPENSSL_1_1_0]
      2330:	symbol=tolower;  lookup in file=/sbin/ntpd [0]
      2330:	symbol=tolower;  lookup in file=/usr/lib/libcap.so.2 [0]
      2330:	symbol=tolower;  lookup in file=/usr/lib/libcrypto.so.1.1 [0]
      2330:	symbol=tolower;  lookup in file=/lib/libgcc_s.so.1 [0]
      2330:	symbol=tolower;  lookup in file=/lib/libc.so [0]
      2330:	binding file /sbin/ntpd [0] to /lib/libc.so [0]: normal symbol `tolower'
      2330:	symbol=__stime64;  lookup in file=/sbin/ntpd [0]
      2330:	symbol=__stime64;  lookup in file=/usr/lib/libcap.so.2 [0]
      2330:	symbol=__stime64;  lookup in file=/usr/lib/libcrypto.so.1.1 [0]
      2330:	symbol=__stime64;  lookup in file=/lib/libgcc_s.so.1 [0]
      2330:	symbol=__stime64;  lookup in file=/lib/libc.so [0]
      2330:	symbol=__stime64;  lookup in file=/lib/libdl.so.2 [0]
      2330:	symbol=__stime64;  lookup in file=/lib/libpthread.so.0 [0]
      2330:	symbol=__stime64;  lookup in file=/lib/ld-linux.so.2 [0]
      2330:	/sbin/ntpd: error: symbol lookup error: undefined symbol: __stime64 (fatal)
/sbin/ntpd: symbol lookup error: /sbin/ntpd: undefined symbol: __stime64
file
      2332:	binding file /usr/lib/liblzma.so.5 [0] to /usr/lib/liblzma.so.5 [0]: normal symbol `lzma_index_block_count'
      2332:	symbol=sysconf;  lookup in file=/usr/bin/file [0]
      2332:	symbol=sysconf;  lookup in file=/usr/lib/libmagic.so.1 [0]
      2332:	symbol=sysconf;  lookup in file=/lib/libc.so [0]
      2332:	binding file /usr/lib/liblzma.so.5 [0] to /lib/libc.so [0]: normal symbol `sysconf'
      2332:	symbol=lzma_lzma_preset;  lookup in file=/usr/bin/file [0]
      2332:	symbol=lzma_lzma_preset;  lookup in file=/usr/lib/libmagic.so.1 [0]
      2332:	symbol=lzma_lzma_preset;  lookup in file=/lib/libc.so [0]
      2332:	symbol=lzma_lzma_preset;  lookup in file=/usr/lib/liblzma.so.5 [0]
      2332:	binding file /usr/lib/liblzma.so.5 [0] to /usr/lib/liblzma.so.5 [0]: normal symbol `lzma_lzma_preset'
      2332:	symbol=pthread_create;  lookup in file=/usr/bin/file [0]
      2332:	symbol=pthread_create;  lookup in file=/usr/lib/libmagic.so.1 [0]
      2332:	symbol=pthread_create;  lookup in file=/lib/libc.so [0]
      2332:	symbol=pthread_create;  lookup in file=/usr/lib/liblzma.so.5 [0]
      2332:	symbol=pthread_create;  lookup in file=/usr/lib/libbz2.so.1.0 [0]
      2332:	symbol=pthread_create;  lookup in file=/usr/lib/libz.so.1 [0]
      2332:	symbol=pthread_create;  lookup in file=/lib/libgcc_s.so.1 [0]
      2332:	symbol=pthread_create;  lookup in file=/lib/ld-linux.so.2 [0]
      2332:	/usr/lib/liblzma.so.5: error: symbol lookup error: undefined symbol: pthread_create (fatal)
/usr/bin/file: symbol lookup error: /usr/lib/liblzma.so.5: undefined symbol: pthread_create

As for files, all was downloaded from original [repository] (http://downloads.openwrt.org/releases/21.02.1/packages/i386_pentium4/packages) and installed by it self. Even if i try to install it downloading a package - the same result.

Suggest me anything that would probably help.

Thank you in advance.

you might want to switch to x86_64.

1 Like

but how it would help? Everything that wasn't download as package works just fine

missing libraries will also cause

I believe there may be an strace package for OpenWrt. If so, can you please share output of that (strace ntpd)?

Possibly this only confirms the ld debug you already posted. Did you do symbol search for _stime64 already?

1 Like

because they came with the image, but as @fodiator said, it might be due missing libs.

i386, you're flogging a dead horse.

here I have to agree with @frollic . Pentium 4 is obviously old and not energy efficient…

i cant find that package (at least for this version of OpenWRT and this architecture).

I don't quite understand what is "symbol searching" but i googled for library where that symbol could be. And it could be in "time.h" which is in "librt" mb. I also got similar error with this lib but i dont know what to do with it except for checking is it there and does it have correct symlink.

I know... I wish i could go on with something modern but i need to support this old scrap at work

Your system was built with glibc as libc implementation. All repository packages are built against musl libc and are not runnable due to that.

You can work around the problem as follows:

  1. Download https://downloads.openwrt.org/releases/21.02.1/targets/x86/generic/openwrt-sdk-21.02.1-x86-generic_gcc-8.4.0_musl.Linux-x86_64.tar.xz to your PC
  2. Extract the archive
  3. Use scp to copy ./staging_dir/toolchain-i386_pentium4_gcc-8.4.0_musl/lib/libc.so as well as the ./staging_dir/toolchain-i386_pentium4_gcc-8.4.0_musl/lib/ld-musl-i386.so.1 symlink to /lib/ on your Atom device.

This will essentially install the musl libc on your system (it can coexist with glibc due to the different ELF interpreter names ld-linux.so.2 vs. ld-musl-i386.so.1 and shared object names libc.so.6 for glibc vs. libc.so for musl).

After that, your system should be able to execute opkg installed packages.

2 Likes

Thank you. It looks like it would work. I'll be back as soon as i try it

well, it's less hopeless than before. But now i got different errors:

root@OpenWrt:/lib# file
Error relocating /usr/lib/libbz2.so.1.0: __strcat_chk: symbol not found
Error relocating /lib/libgcc_s.so.1: __cpu_indicator_init: symbol not found
Error relocating /lib/libgcc_s.so.1: __cpu_model: symbol not found

Errors for ntpd
Error relocating /usr/lib/libcrypto.so.1.1: __register_atfork: symbol not found
Error relocating /usr/lib/libcrypto.so.1.1: __memcpy_chk: symbol not found
Error relocating /usr/lib/libcrypto.so.1.1: __strcat_chk: symbol not found
Error relocating /usr/lib/libcrypto.so.1.1: __syslog_chk: symbol not found
Error relocating /usr/lib/libcrypto.so.1.1: __memset_chk: symbol not found
Error relocating /usr/lib/libcrypto.so.1.1: __fread_chk: symbol not found
Error relocating /usr/lib/libcrypto.so.1.1: __fdelt_chk: symbol not found
Error relocating /lib/libgcc_s.so.1: __cpu_indicator_init: symbol not found
Error relocating /lib/libgcc_s.so.1: __cpu_model: symbol not found
Error relocating /sbin/ntpd: __stime64: symbol not found
Error relocating /sbin/ntpd: __gmtime64: symbol not found
Error relocating /sbin/ntpd: __adjtimex_time64: symbol not found
Error relocating /sbin/ntpd: __clock_settime64: symbol not found
Error relocating /sbin/ntpd: __select_time64: symbol not found
Error relocating /sbin/ntpd: __timer_settime64: symbol not found
Error relocating /sbin/ntpd: __ctime64: symbol not found
Error relocating /sbin/ntpd: __timer_gettime64: symbol not found
Error relocating /sbin/ntpd: __adjtime64: symbol not found
Error relocating /sbin/ntpd: __localtime64: symbol not found
Error relocating /sbin/ntpd: __settimeofday_time64: symbol not found
Error relocating /sbin/ntpd: __utimes_time64: symbol not found
Error relocating /sbin/ntpd: __stat_time64: symbol not found
Error relocating /sbin/ntpd: __fstat_time64: symbol not found
Error relocating /sbin/ntpd: __gettimeofday_time64: symbol not found
Error relocating /sbin/ntpd: __clock_gettime64: symbol not found
Error relocating /sbin/ntpd: __sem_timedwait_time64: symbol not found
Error relocating /sbin/ntpd: __time64: symbol not found
Error relocating /sbin/ntpd: __time64: symbol not found

Ah yes, you likely need a different set of libs for musl (libgcc_s.so1 & friends).

You can try this:

  1. Create a new file called /etc/ld-musl-i386.path
  2. Enter one line with the following content: /lib-musl:/lib:/usr/lib
  3. mkdir /lib-musl
  4. Use scp to copy ./staging_dir/toolchain-i386_pentium4_gcc-8.4.0_musl/lib/libgcc_s.so.1 from the SDK to /lib-musl/ on the target

Repeat the process for any failing library, e.g. libcrypto.so.1.1 . For that it is best to use opkg download libopenssl, then extract the archive (it's a renamed .tar.gz), find the contained .so file and copy it to /lib-musl/ as well. Problem is that you cannot load libraries built against glibc (such as libcrypto.so.1.1 on your system) under musl libc. You do need a separate tree of musl-targeting libraries.

Retry afterwards.

1 Like

shouldn't i add link to the .path file somewhere?
(EDIT: yes, i shound't. i found man page but still got a problem)

i still got same errors.
anyway, that what i did so far

root@OpenWrt:/lib-musl# ls
libcrypto.so.1.1  libgcc_s.so.1     libssl.so.1.1
root@OpenWrt:/lib-musl# cat /etc/ld-musl-i386.path 
/lib-musl:/lib:/usr/lib