I’m attaching a test program that does the following:
• if argv[1] is "-" it just outputs argv[0] and argv[1]
• otherwise it also execve(2)s argv[1] with its argv[0] set to "meow"
I’ve installed the extra packages:
• gcc-arm-linux-gnueabi
• libc6-dev-armel-cross
tglase@tglase-nb:~ $ gcc -Wall -Wextra -o native tst.c
1|tglase@tglase-nb:~ $ ./native ./native
argv[0]: ./native
argv[1]: ./native
calling...
argv[0]: meow
argv[1]: -
not calling
tglase@tglase-nb:~ $ arm-linux-gnueabi-gcc -o cross tst.c -static
tglase@tglase-nb:~ $ ./cross ./cross
argv[0]: ./cross
argv[1]: ./cross
calling...
argv[0]: ./cross
argv[1]: -
not calling
tglase@tglase-nb:~ $ ./cross ./native
argv[0]: ./cross
argv[1]: ./native
calling...
argv[0]: meow
argv[1]: -
not calling
tglase@tglase-nb:~ $ ./native ./cross
argv[0]: ./native
argv[1]: ./cross
calling...
argv[0]: ./cross
argv[1]: -
not calling
As you can see, if the callee of an exec is a qemu-user target,
argv[0] is trashed.
This, among other things, makes qemu-user-static-based buildds unworkable.
-- System Information:
Debian Release: bullseye/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'oldstable-updates'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.7.0-2-amd64 (SMP w/2 CPU threads)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)
Versions of packages qemu-user depends on:
ii libc6 2.31-3
ii libcapstone3 4.0.1+really+3.0.5-2
ii libgcc-s1 10.2.0-7
ii libglib2.0-0 2.66.0-1
ii libgnutls30 3.6.15-2
ii libstdc++6 10.2.0-7
ii zlib1g 1:1.2.11.dfsg-2
Versions of packages qemu-user recommends:
ii qemu-user-static [qemu-user-binfmt] 1:5.1+dfsg-4
Versions of packages qemu-user suggests:
ii sudo 1.9.1-2
-- no debconf information
Hi, what’s the status on this? It is still broken in sid.
Could we please get the fix?
-- System Information:
Debian Release: bullseye/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'oldstable-updates'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.9.0-4-amd64 (SMP w/2 CPU threads)
Kernel taint flags: TAINT_WARN
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)
Versions of packages qemu-user depends on:
ii libc6 2.31-9
ii libcapstone4 4.0.2-3
ii libgcc-s1 10.2.1-6
ii libglib2.0-0 2.66.4-1
ii libgnutls30 3.7.0-5
ii libstdc++6 10.2.1-6
ii zlib1g 1:1.2.11.dfsg-2
Versions of packages qemu-user recommends:
ii qemu-user-static [qemu-user-binfmt] 1:5.2+dfsg-3
qemu-user suggests no packages.
-- no debconf information