2

I have compiled canboat for PiCore64 from my amd64 workstation using docker and qemu. Specifically this is my build script:

#!/bin/sh

set -e

NAME=canboat

cd canboat make all cd ..

mkdir -p ./root/usr/local/bin/ cp canboat/rel/linux-aarch64/* ./root/usr/local/bin/

patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/actisense-serial patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/analyzer patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/analyzer-explain patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/analyzer-explain-j1939 patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/analyzer-j1939 patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/candump2analyzer patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/command-group-function patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/ikonvert-serial patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/iptee patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/n2kd patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/nmea0183-serial patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/replay patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/request-group-function patchelf --replace-needed libc.musl-aarch64.so.1 libc.so.6 --set-interpreter ld-linux-aarch64.so.1 ./root/usr/local/bin/socketcan-writer #exit 1

mksquashfs ./root "$DEST"/"$NAME".tcz -all-root md5sum "$DEST"/"$NAME".tcz > "$DEST"/"$NAME".tcz.md5.txt cp "$NAME".tcz.dep "$DEST" cp "$NAME".tcz.info "$DEST"

Dockerfile:

FROM arm64v8/alpine:3.19

RUN apk add gcc g++ python3 musl-dev make py3-pip py3-virtualenv libxslt libxml2-utils
squashfs-tools py3-yaml py3-urllib3 npm linux-headers patchelf

When I load this extension in PiCore64 14.1.0, I get this output:

$ /tmp/tcloop/canboat/usr/local/bin/actisense-serial
-sh: /tmp/tcloop/canboat/usr/local/bin/actisense-serial: not found

Diagnostics:

$ ls /tmp/tcloop/canboat/usr/local/bin/actisense-serial
/tmp/tcloop/canboat/usr/local/bin/actisense-serial
$ ldd /tmp/tcloop/canboat/usr/local/bin/actisense-serial
linux-vdso.so.1 (0x0000007f81963000)
libc.so.6 => /lib/libc.so.6 (0x0000007f81720000)
ld-linux-aarch64.so.1 => /lib/ld-linux-aarch64.so.1 (0x0000007f881926000)
$ readelf -l /tmp/tcloop/canboat/usr/local/bin/actisense-serial | grep interpr
[Requesting program interpreter: ld-linux-aarch64.so.1]
$ ls /lib
...
ld-linux-aarch64.so.1
...
libc.so.6
...
$ env
USER=tc
SHLVL=1
HOME=/home/tc
PAGER=less -EM
PS1=...
ENV=/home/tc/.ashrc
BACKUP=1
LOGNAME=tc
TERM=linux
PATH=/home/tc/.local/bin:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/sysconfig/tcedir/ondemand
G_FILENAME_ENCODING=iso8859-1
LANG=C
MANPAGER=less -isR
SHELL=/bin/sh
FLWM_TITLEBAR_COLOR=58:7D:AA
PWD=/home/tc
EDITOR=vi
$ strace /tmp/tcloop/canboat/usr/local/bin/actisense-serial
execve("/tmp/tcloop/canboat/usr/local/bin/actisense-serial", ["/tmp/tcloop/canboat/usr/local/bi"...], 0x7fd7ba350 /* 17 vars */) = -1 ENOENT (No such file or directory)
strace: exec: No such file or directory
+++ exited with 1 +++

(...: abbreviated for brevity or my laziness)

So all required shared libraries apparently can be located, but I am still baffled as to why I get the error. Is there some way that I can find what it is looking for that it cannot find? What is it missing?

rhbvkleef
  • 121
  • I think the problem is the same as https://unix.stackexchange.com/questions/76490/no-such-file-or-directory-on-an-executable-yet-file-exists-and-ldd-reports-al : the executable can't find its loader (and ldd can because it always knows where its loader is). I guess it's looking in the wrong directory? Does strings /tmp/tcloop/canboat/usr/local/bin/actisense-serial | grep ld-linux give a clue? – Gilles 'SO- stop being evil' Feb 21 '24 at 10:37
  • It has given me a clue by now. It does list ld correctly, but there's still an entry for libc.musl-aarch64.so.1, which isn't present. It is not in the dynamic section, so I guess I now need to find in which section it is located, and see if I can patch that one out too. – rhbvkleef Feb 21 '24 at 11:50
  • Though I cannot find any mention of musl in readelf -a. – rhbvkleef Feb 21 '24 at 11:51
  • It is listed in the .dynstr section. – rhbvkleef Feb 21 '24 at 11:55

0 Answers0