qemu/scripts
Laurent Vivier 6e1c0d7b95 linux-user: manage binfmt-misc preserve-arg[0] flag
Add --preserve-argv0 in qemu-binfmt-conf.sh to configure the preserve-argv0
flag.

This patch allows to use new flag in AT_FLAGS to detect if
preserve-argv0 is configured for this interpreter:
argv[0] (the full pathname provided by binfmt-misc) is removed and
replaced by argv[1] (the original argv[0] provided by binfmt-misc when
'P'/preserve-arg[0] is set)

For instance with this patch and kernel support for AT_FLAGS:

  $ sudo chroot m68k-chroot sh -c 'echo $0'
  sh

without this patch:

  $ sudo chroot m68k-chroot sh -c 'echo $0'
  /usr/bin/sh

The new flag is available in kernel (v5.12) since:
2347961b11d4 ("binfmt_misc: pass binfmt_misc flags to the interpreter")

This can be tested with something like:

  # cp ..../qemu-ppc /chroot/powerpc/jessie

  # qemu-binfmt-conf.sh --qemu-path / --systemd ppc --credential yes \
                        --persistent no --preserve-argv0 yes
  # systemctl restart systemd-binfmt.service
  # cat /proc/sys/fs/binfmt_misc/qemu-ppc
  enabled
  interpreter //qemu-ppc
  flags: POC
  offset 0
  magic 7f454c4601020100000000000000000000020014
  mask ffffffffffffff00fffffffffffffffffffeffff
  # chroot /chroot/powerpc/jessie  sh -c 'echo $0'
  sh

  # qemu-binfmt-conf.sh --qemu-path / --systemd ppc --credential yes \
                        --persistent no --preserve-argv0 no
  # systemctl restart systemd-binfmt.service
  # cat /proc/sys/fs/binfmt_misc/qemu-ppc
  enabled
  interpreter //qemu-ppc
  flags: OC
  offset 0
  magic 7f454c4601020100000000000000000000020014
  mask ffffffffffffff00fffffffffffffffffffeffff
  # chroot /chroot/powerpc/jessie  sh -c 'echo $0'
  /bin/sh

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210222105004.1642234-1-laurent@vivier.eu>
2021-03-13 10:45:11 +01:00
..
ci scripts/ci/gitlab-pipeline-status: give more info when pipeline not found 2021-03-09 06:03:53 +01:00
coccinelle scripts/coccinelle: New script to remove unnecessary timer_del() calls 2021-01-08 15:13:38 +00:00
codeconverter scripts/codeconverter: Update to latest version 2020-09-18 14:12:32 -04:00
coverity-scan Remove texinfo dependency from docker and CI configs 2020-09-29 17:55:39 +02:00
kvm
modules
oss-fuzz fuzz: fix wrong index in clear_bits 2021-02-08 14:43:54 +01:00
performance
qapi qapi: Fix parse errors for removal of null from schema language 2021-03-05 15:40:50 +01:00
qemu-guest-agent
qemugdb scripts/gdb: implement 'qemu bt' 2021-01-12 12:38:03 +01:00
qmp docs: update to show preferred boolean syntax for -chardev 2021-02-25 14:14:33 +01:00
simplebench simplebench: add bench-backup.py 2021-01-26 14:36:37 +01:00
tracetool scripts/tracetool: Replace the word 'whitelist' 2021-03-09 22:14:26 +01:00
analyse-9p-simpletrace.py
analyse-locks-simpletrace.py
analyze-inclusions
analyze-migration.py nomaintainer: Fix Lesser GPL version number 2020-11-15 17:04:40 +01:00
archive-source.sh
block-coroutine-wrapper.py scripts: add block-coroutine-wrapper.py 2020-10-05 10:59:06 +01:00
check_sparse.py meson: move sparse detection to Meson and rewrite check_sparse.py 2020-10-04 18:36:23 +02:00
checkpatch.pl checkpatch: don't emit warning on newly created acpi data files 2021-02-23 10:58:42 -05:00
clean-header-guards.pl scripts/: fix some comment spelling errors 2020-09-17 20:37:55 +02:00
clean-includes
cleanup-trace-events.pl scripts/cleanup-trace-events: Emit files in alphabetical order 2020-09-09 17:17:00 +01:00
cocci-macro-file.h compiler.h: remove QEMU_GNUC_PREREQ 2020-12-15 12:53:15 -05:00
coverity-model.c
decodetree.py decodetree: Open files with encoding='utf-8' 2021-01-13 08:39:08 -10:00
device-crash-test device-crash-test: Remove problematic language 2021-02-18 18:34:47 -05:00
disas-objdump.pl
dump-guest-memory.py
entitlement.sh hvf: Sign the code after installation 2021-02-25 13:57:34 +01:00
extract-vsssdk-headers
feature_to_c.sh
fix-multiline-comments.sh docs: move CODING_STYLE into the developer documentation 2021-02-24 11:05:21 +00:00
gensyscalls.sh Hexagon (linux-user/hexagon) Linux user emulation 2021-02-18 07:48:22 -08:00
get_maintainer.pl get_maintainer: update repo URL to GitLab 2021-02-09 20:53:56 +00:00
git-submodule.sh configure: replace --enable/disable-git-update with --with-git-submodules 2021-01-29 17:07:53 +00:00
git.orderfile scripts/git.orderfile: Keep files with .inc extension sorted 2020-12-15 12:53:16 -05:00
hxtool
hxtool-conv.pl
kernel-doc scripts: kernel-doc: remove unnecessary change wrt Linux 2020-12-10 12:15:25 -05:00
make-release
meson.build
minikconf.py
mtest2make.py meson: Re-enable the possibility to run "make check SPEED=slow" 2021-03-09 06:03:53 +01:00
nsis.py meson: Fix argument for makensis (build regression) 2020-11-18 09:28:55 +01:00
qapi-gen.py qapi: move generator entrypoint into package 2020-10-10 11:37:47 +02:00
qemu-binfmt-conf.sh linux-user: manage binfmt-misc preserve-arg[0] flag 2021-03-13 10:45:11 +01:00
qemu-gdb.py scripts/gdb: implement 'qemu bt' 2021-01-12 12:38:03 +01:00
qemu-trace-stap
qemu-version.sh build-sys: fix git version from -version 2020-10-12 11:50:23 -04:00
refresh-pxe-roms.sh
render_block_graph.py
replay-dump.py nomaintainer: Fix Lesser GPL version number 2020-11-15 17:04:40 +01:00
shaderinclude.pl
show-fixed-bugs.sh
signrom.py
simpletrace.py simpletrace: build() missing 2 required positional arguments 2021-02-01 10:51:00 +00:00
switch-timer-api
tap-driver.pl
tap-merge.pl
test-driver.py
tracetool.py tracetool: add output filename command-line argument 2021-01-04 14:24:58 +00:00
u2f-setup-gen.py
undefsym.py build: fix macOS --enable-modules build 2020-10-22 11:53:52 -04:00
update-linux-headers.sh update-linux-headers: Include const.h 2021-01-21 11:19:45 +01:00
update-mips-syscall-args.sh
update-syscalltbl.sh
userfaultfd-wrlat.py migration: introduce 'userfaultfd-wrlat.py' script 2021-02-08 11:19:51 +00:00
vmstate-static-checker.py