linux-user: --strace incorrectly decodes writev arguments for 64-bit binaries on 32-bit machine
Host environment
- Operating system: Gentoo
- OS/kernel version:
Linux t60 5.10.88-gentoo-dist #1 SMP Wed Dec 22 15:58:38 -00 2021 i686 Genuine Intel(R) CPU T2400 @ 1.83GHz GenuineIntel GNU/Linux - Architecture: i686
- QEMU flavor: qemu-aarch64, qemu-x86_64
- QEMU version: 6.2.0
- QEMU command line:
qemu-x86_64 --strace ./aarch64-main
Emulated/Virtualized environment
- Operating system: linux-user
- OS/kernel version: linux-user
- Architecture: x86_64, aarch64
Description of problem
With --strace, the arguments to writev appear to be decoded incorrectly.
The syscall still succeeds and has the expected effects.
Steps to reproduce
$ cat main.c
#include <sys/uio.h>
int main(void) {
struct iovec iov;
iov.iov_base = "hello, world!\n";
iov.iov_len = 14;
return writev(1, &iov, 1);
}
$ aarch64-unknown-linux-gnu-gcc -static -o aarch64-main main.c
$ x86_64-pc-linux-gnu-gcc -static -o x86_64-main main.c
$ i686-pc-linux-gnu-gcc -static -o i686-main main.c
$ ./i686-main
hello, world!
$ strace ./i686-main |& grep writev
writev(1, [{iov_base="hello, world!\n", iov_len=14}], 1hello, world!
$ qemu-i386 --strace ./i686-main |& grep writev
21953 writev(1,0x407ffe54,0x1) = 14
$ qemu-x86_64 --strace ./x86_64-main |& grep writev
22218 writev(1,(nil),0x407ffcc0) = 14
$ qemu-aarch64 --strace ./aarch64-main |& grep writev
22523 writev(1,(nil),0x407ffcc8) = 14