Hi,
Over the recent week, I have been working to get OSv to run a simple "hello
world" app (aka native-example) built as a position-dependent statically
linked executable. In essence, I picked up where Pekka Enberg left over 8
years ago (see https://github.com/cloudius-systems/osv/tree/static-elf).
Obviously, given these days OSv has pretty robust support of over 70
syscalls (and 60 more that should be trivial to add), and the remaining
work is much more manageable.
./scripts/firecracker.py -e /hello
OSv v0.57.0-37-g0de155a4
Booted up in 5.23 ms
Cmdline: /hello
-> syscall: 107
-> syscall: 102
-> syscall: 108
-> syscall: 104
-> syscall: 158
-> syscall: 012
-> syscall: 012
-> syscall: 158
-> syscall: 218
-> syscall: 273
-> syscall: 063
-> syscall: 302
-> syscall: 089
-> syscall: 318
-> syscall: 228
-> syscall: 228
-> syscall: 012
-> syscall: 012
-> syscall: 010
-> syscall: 262
-> syscall: 016
-> syscall: 001
Hello from C code
-> syscall: 231
I will be sending a series of proper patches later after I clean some
issues but in essence here is a list of things I had to do including what
Pekka started:
1. Tweak dynamic linker to support static executable:
- Handle missing DT_SYMTAB, DT_STRTAB and DT_NEEDED.
- Handle ET_EXEC
- Support statically-linked executable base address
2. Add basic handling of static ELF entry point and initial stack state
setup (see figure 3.9 ("Initial Process Stack") of the x86-64 ABI
specification - https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf
- make sure the RDX registers in zeroed and the basic AUX vector with
AT_RANDOM is set up
- more is left to do to fully support argv and full aux vector
3. Add support of the brk() syscall (see issue 1138)
4. Add dummy support of sys_set_robust_list and set_tid_address syscalls
(possibly needs something more for multithreaded apps).
5. Support the arch_prctl syscall that sets the app TLS
- this was by far the most complicated element that required changing
OSv to store new per-pcpu data pointer in GS register and enhancing both
syscall handler and interrupt/page fault handler to detect and switch if
needed the FS base to the kernel TLS on entry and back to the app one on
exit
(see
https://github.com/cloudius-systems/osv/issues/1137#issuecomment-1512315880)
6. Fixing a potential bug in handling TCGETS in the console driver.
7. Implement sys_prlimit
8. Enable the readlink, geteuid and getegid
This was enough to run a single-threaded app but we will need to implement
the clone syscall to support multi-threaded apps. In addition, we would
want to support the static pies as well which I hope should not be very
difficult.
Regards,
Waldek
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/osv-dev/3a561595-e072-4980-8375-3b742717dd6dn%40googlegroups.com.