running binary in chroot using qemu-arm-static fails to mmap after r320318

From: Guy Yur <>
Date: Sat, 1 Jul 2017 22:46:58 +0300

I tried to run armv6 /bin/sh in a chroot on an
amd64 host using qemu-arm-static.
It failed on invalid argument to mmap.

# cp /usr/local/bin/qemu-arm-static /chroots/armv6/root/
# chroot /chroots/armv6 /root/qemu-arm-static /bin/sh
/lib/ mmap of entire address space failed: Invalid argument

rtld-elf only passes MAP_GUARD but ktrace shows mmap
is called with MAP_FIXED and MAP_ANON too.
I think qemu-user-static adds the flags in bsd-user/mmap.c target_mmap().
Does the qemu-user-static port need patching to support MAP_GUARD?

ktrace snipet:
  1072 qemu-arm-static CALL
  1072 qemu-arm-static NAMI  "/lib/"
  1072 qemu-arm-static RET   openat 3
  1072 qemu-arm-static CALL  fstat(0x3,0x7ffffffe9680)
  1072 qemu-arm-static STRU  struct stat {dev=687931144, ino=192007,
mode=0100444, nlink=1, uid=0, gid=0, rdev=1548632,
atime=1498921861.605975000, mtime=1498921861.608547000,
ctime=1498921861.609724000, birthtime=1498921861.605973000,
size=1720888, blksize=32768, blocks=3456, flags=0x20000 }
  1072 qemu-arm-static RET   fstat 0
  1072 qemu-arm-static CALL
  1072 qemu-arm-static RET   mmap 4110381056/0xf4ff7000
  1072 qemu-arm-static CALL
  1072 qemu-arm-static RET   mmap 4110381056/0xf4ff7000
  1072 qemu-arm-static CALL
  1072 qemu-arm-static RET   mmap -1 errno 22 Invalid argument

Received on Sat Jul 01 2017 - 17:47:02 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:12 UTC