2

My current setup is quite exotic, and I could use some clarification.

I am running on a Pinebook Pro, powered by a Quad Cortex-A53, 64-bit CPU. The OS is a 64-bit version of Debian:

$ uname -a
Linux pinebook 4.4.196 #1 SMP Tue Oct 15 16:54:21 EDT 2019 aarch64 GNU/Linux

By default however only armhf architecture was enabled:

$ dpkg --print-architecture
armhf

Since I wanted to run aarch64 binaries I added the corresponding architecture:

$ dpkg --add-architecture arm64
$ apt update && apt upgrade
$ apt install gcc-6-base:arm64 libc6:arm64 libgcc1:arm64

This worked without problems. However, after this I found myself not being able to run another 32-bit binary anymore because suddenly /lib/ld-linux.so.3 had disappeared. Inspecting it gave me the following output.

$ file openocd 
openocd: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=363651b03c33118c80584e99b6f876c7a8663325, stripped

Indeed, ld-linux.so.3 was missing. In its place I found architecture-specific symbolic links:

$ ls /lib
aarch64-linux-gnu    firmware               ld-linux-armhf.so.3  systemd
arm-linux-gnueabihf  ifupdown               lsb                  terminfo
cpp                  init                   modprobe.d           udev
dhcpcd               ld-linux-aarch64.so.1  modules           

Since I needed ld-linux.so.3 from armhf architecture I looked for it under /lib/arm-linux-gnueabihf/ and sure enough there it was. To solve my problem I then linked it in /lib, and the binary worked again.

$ ln -s /lib/arm-linux-gnueabihf/ld-linux.so.3 /lib/ld-linux.so.3

Now, the question: to fix this problem I had to mess directly with /lib, which is not ideal. What would be the preferred solution?

Maldus
  • 189
  • 1
  • 2
  • 12

1 Answers1

1

Compile the application on such multi-arch system, patch the interp for it (patchelf --set-interpreter /lib/ld-linux-armhf.so.3 /usr/local/bin/openocd) if You cannot. Or call the dynamically linked binary explicitly through the corresponding dynamic linker (/lib/ld-linux-armhf.so.3 /usr/local/bin/openocd). You could do the last by wrappping the command name in a script or alias and move the acutal binary out of the way.

user301446
  • 586
  • 2
  • 6