qemu-user-mode.adoc 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. === QEMU user mode
  2. This has nothing to do with the Linux kernel, but it is cool:
  3. ....
  4. sudo apt-get install qemu-user
  5. ./build -a arm
  6. cd buildroot/output.arm~/target
  7. qemu-arm -L . bin/ls
  8. ....
  9. This uses QEMU's user-mode emulation mode that allows us to run cross-compiled userland programs directly on the host.
  10. The reason this is cool, is that `ls` is not statically compiled, but since we have the Buildroot image, we are still able to find the shared linker and the shared library at the given path.
  11. In other words, much cooler than:
  12. ....
  13. arm-linux-gnueabi-gcc -o hello -static hello.c
  14. qemu-arm hello
  15. ....
  16. It is also possible to compile QEMU user mode from source with `BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=y`, but then your compilation will likely fail with:
  17. ....
  18. package/qemu/qemu.mk:110: *** "Refusing to build qemu-user: target Linux version newer than host's.". Stop.
  19. ....
  20. since we are using a bleeding edge kernel, which is a sanity check in the Buildroot QEMU package.
  21. Anyways, this warns us that the userland emulation will likely not be reliable, which is good to know. TODO: where is it documented the host kernel must be as new as the target one?
  22. GDB step debugging is also possible with:
  23. ....
  24. qemu-arm -g 1234 -L . bin/ls
  25. ../host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gdb -ex 'target remote localhost:1234'
  26. ....
  27. TODO: find source. Lazy now.