11.5. User mode static executables
Example:
./build-userland \ --arch aarch64 \ --static \ ; ./run \ --arch aarch64 \ --static \ --userland userland/c/command_line_arguments.c \ --cli-args 'asdf "qw er"' \ ;
Running dynamically linked executables in QEMU requires pointing it to the root filesystem with the -L
option so that it can find the dynamic linker and shared libraries, see also:
We pass -L
by default, so everything just works.
However, in case something goes wrong, you can also try statically linked executables, since this mechanism tends to be a bit more stable, for example:
-
QEMU x86_64 guest on x86_64 host was failing with stack smashing detected when using glibc, but we found a workaround
-
gem5 user only supported static executables in the past, as mentioned at: Section 11.7, “gem5 syscall emulation mode”
Running statically linked executables sometimes makes things break:
-
TODO understand why:
./run --static --userland userland/c/file_write_read.c
fails our assertion that the data was read back correctly:
Assertion `strcmp(data, output) == 0' faile