mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-01-18 05:45:29 -07:00
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>
|
||
|---|---|---|
| .. | ||
| ci | ||
| coccinelle | ||
| codeconverter | ||
| coverity-scan | ||
| kvm | ||
| modules | ||
| oss-fuzz | ||
| performance | ||
| qapi | ||
| qemu-guest-agent | ||
| qemugdb | ||
| qmp | ||
| simplebench | ||
| tracetool | ||
| analyse-9p-simpletrace.py | ||
| analyse-locks-simpletrace.py | ||
| analyze-inclusions | ||
| analyze-migration.py | ||
| archive-source.sh | ||
| block-coroutine-wrapper.py | ||
| check_sparse.py | ||
| checkpatch.pl | ||
| clean-header-guards.pl | ||
| clean-includes | ||
| cleanup-trace-events.pl | ||
| cocci-macro-file.h | ||
| coverity-model.c | ||
| decodetree.py | ||
| device-crash-test | ||
| disas-objdump.pl | ||
| dump-guest-memory.py | ||
| entitlement.sh | ||
| extract-vsssdk-headers | ||
| feature_to_c.sh | ||
| fix-multiline-comments.sh | ||
| gensyscalls.sh | ||
| get_maintainer.pl | ||
| git-submodule.sh | ||
| git.orderfile | ||
| hxtool | ||
| hxtool-conv.pl | ||
| kernel-doc | ||
| make-release | ||
| meson.build | ||
| minikconf.py | ||
| mtest2make.py | ||
| nsis.py | ||
| qapi-gen.py | ||
| qemu-binfmt-conf.sh | ||
| qemu-gdb.py | ||
| qemu-trace-stap | ||
| qemu-version.sh | ||
| refresh-pxe-roms.sh | ||
| render_block_graph.py | ||
| replay-dump.py | ||
| shaderinclude.pl | ||
| show-fixed-bugs.sh | ||
| signrom.py | ||
| simpletrace.py | ||
| switch-timer-api | ||
| tap-driver.pl | ||
| tap-merge.pl | ||
| test-driver.py | ||
| tracetool.py | ||
| u2f-setup-gen.py | ||
| undefsym.py | ||
| update-linux-headers.sh | ||
| update-mips-syscall-args.sh | ||
| update-syscalltbl.sh | ||
| userfaultfd-wrlat.py | ||
| vmstate-static-checker.py | ||