# Linux Kernel Module Cheat

##### 2.8.2.2. Userland setup getting started with prebuilt toolchain and QEMU user mode

If you are lazy to built the Buildroot toolchain and QEMU, but want to run e.g. ARM Userland assembly in User mode simulation, you can get away on Ubuntu 18.04 with just:

    sudo apt-get install gcc-aarch64-linux-gnu qemu-system-aarch64
    ./build-userland \
      --arch aarch64 \
      --gcc-which host \
      --userland-build-id host \
    ;
    ./run \
      --arch aarch64 \
      --qemu-which host \
      --userland-build-id host \
      --userland userland/c/command_line_arguments.c \
      --cli-args 'asdf "qw er"' \
    ;

where:

- `--gcc-which host`: use the host toolchain.

  We must pass this to `./run` as well because QEMU must know which dynamic libraries to use. See also: Section 11.5, “User mode static executables”.

- `--userland-build-id host`: put the host built into a Build variants

This present the usual trade-offs of using prebuilts as mentioned at: Section 2.6, “Prebuilt setup”.

Other functionality are analogous, e.g. testing:

    ./test-executables \
      --arch aarch64 \
      --gcc-which host \
      --qemu-which host \
      --userland-build-id host \
    ;

and User mode GDB:

    ./run \
      --arch aarch64 \
      --gdb \
      --gcc-which host \
      --qemu-which host \
      --userland-build-id host \
      --userland userland/c/command_line_arguments.c \
      --cli-args 'asdf "qw er"' \
    ;