Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: Enable CONFIG_CONSTRUCTORS

We do need to call the constructors for *modules*, and
at least for KASAN in the future, we must call even the
kernel constructors only later when the kernel has been
initialized.

Instead of relying on libc to call them, emit an empty
section for libc and let the kernel's CONSTRUCTORS code
do the rest of the job.

Tested that it indeed doesn't work in modules, and does
work after the fixes in both, with a few functions with
__attribute__((constructor)) in both dynamic and static
builds.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Johannes Berg and committed by
Richard Weinberger
786b2384 324f80cc

+2 -4
+1 -1
arch/um/include/asm/common.lds.S
··· 83 83 __preinit_array_end = .; 84 84 } 85 85 .init_array : { 86 + /* dummy - we call this ourselves */ 86 87 __init_array_start = .; 87 - *(.init_array) 88 88 __init_array_end = .; 89 89 } 90 90 .fini_array : {
-1
arch/um/kernel/dyn.lds.S
··· 103 103 be empty, which isn't pretty. */ 104 104 . = ALIGN(32 / 8); 105 105 .preinit_array : { *(.preinit_array) } 106 - .init_array : { *(.init_array) } 107 106 .fini_array : { *(.fini_array) } 108 107 .data : { 109 108 INIT_TASK_DATA(KERNEL_STACK_SIZE)
-1
init/Kconfig
··· 48 48 49 49 config CONSTRUCTORS 50 50 bool 51 - depends on !UML 52 51 53 52 config IRQ_WORK 54 53 bool
+1 -1
kernel/gcov/Kconfig
··· 4 4 config GCOV_KERNEL 5 5 bool "Enable gcov-based kernel profiling" 6 6 depends on DEBUG_FS 7 - select CONSTRUCTORS if !UML 7 + select CONSTRUCTORS 8 8 default n 9 9 ---help--- 10 10 This option enables gcov-based code profiling (e.g. for code coverage