The weak syscall symbols generated by gen_syscalls.py are currently
compiled in the LLEXT subsystem library, which is then linked among all
other Zephyr libraries in an unspecified order. This can cause the weak
symbols to override the actual syscall implementations, leading to
undefined behaviour.
To fix this, the currently generated file is split in two elements:
- syscall_exports_llext.c contains the EXPORT_SYMBOL directives for all
syscalls. This part can be compiled with the LLEXT library and linked
among all other Zephyr libraries, and ensures all syscalls symbols
are preserved by the linker.
- syscall_weakdefs_llext.c contains the weak definitions for all syscalls.
This file is compiled in a separate library that is linked last, so
that the weak symbols are only used if no other implementation is
available.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>