Add config option to delay libc initialisation The initialisation of libc should occur after system calls have been initalised. Some calls are initialised externally or have external dependencies. Signed-off-by: Curtis Millar <curtis.millar@data61.csiro.au>
diff --git a/libsel4muslcsys/CMakeLists.txt b/libsel4muslcsys/CMakeLists.txt index c7ae46f..336a75c 100644 --- a/libsel4muslcsys/CMakeLists.txt +++ b/libsel4muslcsys/CMakeLists.txt
@@ -53,6 +53,17 @@ DEFAULT OFF ) + +config_string( + LibSel4MuslcSysConstructorPriority + LIB_SEL4_MUSLC_SYS_CONSTRUCTOR_PRIORITY + "Set the priority of the muslc initialisation constructors such that + they occur after external initialisation of the system call + dependencies." + DEFAULT + "CONSTRUCTOR_MIN_PRIORITY + 1" + UNQUOTE +) mark_as_advanced( LibSel4MuslcSysMorecoreBytes LibSel4MuslcSysDebugHalt
diff --git a/libsel4muslcsys/src/vsyscall.c b/libsel4muslcsys/src/vsyscall.c index e9f1b4e..bad8ace 100644 --- a/libsel4muslcsys/src/vsyscall.c +++ b/libsel4muslcsys/src/vsyscall.c
@@ -221,7 +221,7 @@ * it can be overriden. We are able to have this constructor * in this file since we know it will get looked at by the linker due * to __vsyscall_ptr being here */ -static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY + 1) init_syscall_table(void) +static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) init_syscall_table(void) { muslcsys_syscall_t ret UNUSED; ret = muslcsys_install_syscall(__NR_set_tid_address, sys_set_tid_address); @@ -242,7 +242,7 @@ #ifdef CONFIG_LIB_SEL4_MUSLC_SYS_CPIO_FS extern char _cpio_archive[]; extern char _cpio_archive_end[]; -static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY + 1) install_default_cpio(void) +static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) install_default_cpio(void) { unsigned long cpio_len = _cpio_archive_end - _cpio_archive; muslcsys_install_cpio_interface(_cpio_archive, cpio_len, cpio_get_file); @@ -300,7 +300,7 @@ extern void __init_libc(char const *const *envp, char const *pn); /* Initialise muslc environment */ -void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) muslcsys_init_muslc(void) +void CONSTRUCTOR(CONFIG_LIB_SEL4_MUSLC_SYS_CONSTRUCTOR_PRIORITY) muslcsys_init_muslc(void) { seL4_IPCBuffer *tmp = __sel4_ipc_buffer; __init_libc(sel4runtime_envp(), sel4runtime_argv()[0]);