Attached debdiff makes use of the --fix-binary option added in binfmt-support 2.1.7, which sets the "F" flag in the binfmt entry. I tested this on amd64 stretch (with binfmt-support-2.1.7-1 from sid). I created a chroot with debootstrap --arch=armhf and then chrooted into it. It worked correctly and I was able to run the armhf binaries with no changes besides installing qemu-user-static.
I left qemu-user-binfmt without the --fix-binary flag since it seems unlikely that would work as well with dynamic linking and shared libraries. It can easily be changed to require binfmt-support 2.1.7 in both cases and pass --fix-binary unconditionally. -- Dan
From e09b030e49ca67d3eb7a53884580bc4b67116e86 Mon Sep 17 00:00:00 2001 From: Dan Nicholson <nichol...@endlessm.com> Date: Mon, 17 Jul 2017 10:03:23 -0500 Subject: [PATCH] Use binfmt-support --fix-binary option (#868030) binfmt-support 2.1.7 added the --fix-binary boolean option that maps to the kernel's F binfmt flag[1]. This flag instructs the kernel to open the binfmt handler immediately when registered. This is very helpful in the case of qemu-user-static where emulation of another architecture can be handled with no updates to a chroot or container running foreign architecture binaries. However, in the case of qemu-user and qemu-update-binfmt, this is less likely to be helpful since dynamic linking would still require the many libraries in the alternate root. In that case, continue to run update-binfmts without --fix-binary. 1. https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html --- debian/binfmt-update-in | 2 +- debian/control-in | 2 +- debian/rules | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/debian/binfmt-update-in b/debian/binfmt-update-in index aedf6dc..7c0da5d 100644 --- a/debian/binfmt-update-in +++ b/debian/binfmt-update-in @@ -86,7 +86,7 @@ case "$DPKG_MAINTSCRIPT_NAME:$1" in eval "case $fmt in $omit) magic= ;; *) magic=\"\$${fmt}_magic\" mask=\"\$${fmt}_mask\" ;; esac" if [ -n "$magic" ]; then update-binfmts --package @PACKAGE@ --install qemu-$fmt /usr/bin/qemu-$fmt@SUFFIX@ \ - --magic "$magic" --mask "$mask" --offset 0 --credential yes + --magic "$magic" --mask "$mask" --offset 0 --credential yes @FIX_BINARY@ else remove_binfmt $fmt fi diff --git a/debian/control-in b/debian/control-in index 0aaf556..e80e7b3 100644 --- a/debian/control-in +++ b/debian/control-in @@ -435,7 +435,7 @@ Architecture: amd64 arm arm64 armel armhf hppa i386 ia64 mips mipsel powerpc pow Built-Using: ${built-using} Multi-Arch: foreign Depends: ${shlibs:Depends}, ${misc:Depends} -Recommends: binfmt-support +Recommends: binfmt-support (>= 2.1.7) Provides: qemu-user-binfmt Conflicts: qemu-user-binfmt Suggests: sudo diff --git a/debian/rules b/debian/rules index 3c8d74f..d8d9e6a 100755 --- a/debian/rules +++ b/debian/rules @@ -253,9 +253,9 @@ ifeq ($(enable_linux_user),enable) # binfmt support for x in postinst prerm; do \ - sed -e s/@SUFFIX@/-static/ -e s/@PACKAGE@/qemu-user-static/ \ + sed -e s/@SUFFIX@/-static/ -e s/@PACKAGE@/qemu-user-static/ -e "s/@FIX_BINARY@/--fix-binary yes/" \ debian/binfmt-update-in >> debian/qemu-user-static.$$x.debhelper ; \ - sed -e s/@SUFFIX@// -e s/@PACKAGE@/qemu-user-binfmt/ \ + sed -e s/@SUFFIX@// -e s/@PACKAGE@/qemu-user-binfmt/ -e s/@FIX_BINARY@// \ debian/binfmt-update-in >> debian/qemu-user-binfmt.$$x.debhelper ; \ done -- 2.5.5