This was working on Ubuntu until recently.
I have had a dual 32/64 bit development environment for several year and recently my 32 bit apps have stopped running.
This seems to fail sometimes because the binfmt-support service fails to start. (However even on new clean install of Ubuntu where the service does not fail 32 bit binaries refuse to run.)
Here is the error:
The job identifier is 202.
Feb 13 14:59:06 WZ-M18xR2 update-binfmts[864]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
Feb 13 14:59:06 WZ-M18xR2 update-binfmts[864]: update-binfmts: exiting due to previous errors
Feb 13 14:59:06 WZ-M18xR2 systemd[1]: binfmt-support.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ An ExecStart= process belonging to unit binfmt-support.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 2.
Feb 13 14:59:06 WZ-M18xR2 systemd[1]: binfmt-support.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit binfmt-support.service has entered the 'failed' state with result 'exit-code'.
Feb 13 14:59:06 WZ-M18xR2 systemd[1]: Failed to start Enable support for additional executable binary formats.
Finding another old reference that this might be caused by a conflict with systemd-binfmt I stopped systemd-binfmt and tried to restart binfmt-support but still the same error.
However even on a clean built system without this error the 32 bit binaries refuse to run with this error:
bash: ./my32app: cannot execute binary file: Exec format error
If I try this:
/lib32/ld-linux.so.2 ./my32app
./my32app: error while loading shared libraries: ./dcc: cannot open shared object file: No such file or directory
or this:
usr/bin/qemu-i386-static ./dcc
qemu-i386-static: ./my32app: Invalid ELF image for this architecture
readelf show the only dependency is:
readelf -d ./my32app | grep NEEDED
0x00000001 (NEEDED) Shared library: [libc.so.6]
And libc.so.6 can definitely be found in /lib32
And here is a list of all the installed i386 packages:
dpkg -l | awk '/^ii/ && $4 == "i386" { print }'
ii gcc-12-base:i386 12.3.0-1ubuntu1~22.04 i386 GCC, the GNU Compiler Collection (base package)
ii libblkid1:i386 2.37.2-4ubuntu3 i386 block device ID library
ii libbz2-1.0:i386 1.0.8-5build1 i386 high-quality block-sorting file compressor library - runtime
ii libc6:i386 2.35-0ubuntu3.6 i386 GNU C Library: Shared libraries
ii libcap2:i386 1:2.44-1ubuntu0.22.04.1 i386 POSIX 1003.1e capabilities (library)
ii libcom-err2:i386 1.46.5-2ubuntu1.1 i386 common error description library
ii libcrypt1:i386 1:4.4.27-1 i386 libcrypt shared library
ii libdb5.3:i386 5.3.28+dfsg1-0.8ubuntu3 i386 Berkeley v5.3 Database Libraries [runtime]
ii libdbus-1-3:i386 1.12.20-2ubuntu4.1 i386 simple interprocess messaging system (library)
ii libgamemode0:i386 1.6.1-1build2 i386 Optimise Linux system performance on demand (host library)
ii libgamemodeauto0:i386 1.6.1-1build2 i386 Optimise Linux system performance on demand (client library)
ii libgcc-s1:i386 12.3.0-1ubuntu1~22.04 i386 GCC support library
ii libgcrypt20:i386 1.9.4-3ubuntu3 i386 LGPL Crypto library - runtime library
ii libgmp10:i386 2:6.2.1+dfsg-3ubuntu1 i386 Multiprecision arithmetic library
ii libgpg-error0:i386 1.43-3 i386 GnuPG development runtime library
ii libgpm2:i386 1.20.7-10build1 i386 General Purpose Mouse - shared library
ii libgssapi-krb5-2:i386 1.19.2-2ubuntu0.3 i386 MIT Kerberos runtime libraries - krb5 GSS-API Mechanism
ii libidn2-0:i386 2.3.2-2build1 i386 Internationalized domain names (IDNA2008/TR46) library
ii libk5crypto3:i386 1.19.2-2ubuntu0.3 i386 MIT Kerberos runtime libraries - Crypto Library
ii libkeyutils1:i386 1.6.1-2ubuntu3 i386 Linux Key Management Utilities (library)
ii libkrb5-3:i386 1.19.2-2ubuntu0.3 i386 MIT Kerberos runtime libraries
ii libkrb5support0:i386 1.19.2-2ubuntu0.3 i386 MIT Kerberos runtime libraries - Support library
ii liblz4-1:i386 1.9.3-2build2 i386 Fast LZ compression algorithm library - runtime
ii liblzma5:i386 5.2.5-2ubuntu1 i386 XZ-format compression library
ii libmount1:i386 2.37.2-4ubuntu3 i386 device mounting library
ii libncurses5:i386 6.3-2ubuntu0.1 i386 shared libraries for terminal handling (legacy version)
ii libncurses6:i386 6.3-2ubuntu0.1 i386 shared libraries for terminal handling
ii libncursesw6:i386 6.3-2ubuntu0.1 i386 shared libraries for terminal handling (wide character support)
ii libnsl2:i386 1.3.0-2build2 i386 Public client interface for NIS(YP) and NIS+
ii libnss-nis:i386 3.1-0ubuntu6 i386 NSS module for using NIS as a naming service
ii libnss-nisplus:i386 1.3-0ubuntu6 i386 NSS module for using NIS+ as a naming service
ii libpcre2-8-0:i386 10.39-3ubuntu0.1 i386 New Perl Compatible Regular Expression Library- 8 bit runtime files
ii libpcre3:i386 2:8.39-13ubuntu0.22.04.1 i386 Old Perl 5 Compatible Regular Expression Library - runtime files
ii libselinux1:i386 3.3-1build2 i386 SELinux runtime shared libraries
ii libssl3:i386 3.0.2-0ubuntu1.14 i386 Secure Sockets Layer toolkit - shared libraries
ii libstdc++6:i386 12.3.0-1ubuntu1~22.04 i386 GNU Standard C++ Library v3
ii libsystemd0:i386 249.11-0ubuntu3.11 i386 systemd utility library
ii libtinfo5:i386 6.3-2ubuntu0.1 i386 shared low-level terminfo library (legacy version)
ii libtinfo6:i386 6.3-2ubuntu0.1 i386 shared low-level terminfo library for terminal handling
ii libtirpc3:i386 1.3.2-2ubuntu0.1 i386 transport-independent RPC library
ii libudev1:i386 249.11-0ubuntu3.11 i386 libudev shared library
ii libunistring2:i386 1.0-1 i386 Unicode string library for C
ii libuuid1:i386 2.37.2-4ubuntu3 i386 Universally Unique ID library
ii libzstd1:i386 1.4.8+dfsg-3build1 i386 fast lossless compression algorithm
ii zlib1g:i386
Looking in /usr/share/binfmt I do not see an format for ELF 32 bit support:
ls /usr/share/binfmts/
cli qemu-arm qemu-mips64el qemu-s390x
jar qemu-armeb qemu-mipsel qemu-sh4
llvm-11-runtime.binfmt qemu-cris qemu-mipsn32 qemu-sh4eb
llvm-12-runtime.binfmt qemu-hexagon qemu-mipsn32el qemu-sparc
llvm-14-runtime.binfmt qemu-hppa qemu-ppc qemu-sparc32plus
python2.7 qemu-m68k qemu-ppc64 qemu-sparc64
python3.10 qemu-microblaze qemu-ppc64le qemu-xtensa
qemu-aarch64 qemu-mips qemu-riscv32 qemu-xtensaeb
qemu-alpha qemu-mips64 qemu-riscv64
So I tried adding support from this post (Trying (and failing) to run Hello World 32-bit C++ program on 64-bit Ubuntu on Windows 10)
sudo apt install qemu-user-static
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
sudo service binfmt-support start
But that didn't work either. Looking at the hexdump of one of the 32 binaries didn't convince me that the magic value was correct!
hexdump ./dcc | head
0000000 457f 464c 0101 0001 0000 0000 0000 0000
0000010 0003 003e 0001 0000 1300 0000 0034 0000
0000020 7320 0000 0000 0000 0034 0020 000c 0028
0000030 0025 0024 0006 0000 0034 0000 0034 0000
0000040 0034 0000 0180 0000 0180 0000 0004 0000
0000050 0004 0000 0003 0000 01b4 0000 01b4 0000
0000060 01b4 0000 001a 0000 001a 0000 0004 0000
0000070 0001 0000 0001 0000 0000 0000 0000 0000
0000080 0000 0000 0908 0000 0908 0000 0004 0000
0000090 1000 0000 0001 0000 1000 0000 1000 0000
So I am unable to determine how to get 32 bit binaries (that previously worked) to run under Ubuntu.
Any ideas appreciated.
This problem occurs because x32 architecture support has been removed from the Ubuntu kernel after 5.16. From 5.17 onwards while x32 binaries are still supported in the tool chain they are no longer support in the kernel.
Solutions :
Staying on Ubuntu (Mate):
Otherwise:
I managed to test this on Armbian for X86_64 kernel 6.2 and x32 is still supported.