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>
This commit is contained in:
Johannes Berg 2019-08-23 15:36:50 +02:00 committed by Richard Weinberger
parent 324f80cc3e
commit 786b2384bf
4 changed files with 2 additions and 4 deletions

View File

@ -83,8 +83,8 @@
__preinit_array_end = .; __preinit_array_end = .;
} }
.init_array : { .init_array : {
/* dummy - we call this ourselves */
__init_array_start = .; __init_array_start = .;
*(.init_array)
__init_array_end = .; __init_array_end = .;
} }
.fini_array : { .fini_array : {

View File

@ -103,7 +103,6 @@ SECTIONS
be empty, which isn't pretty. */ be empty, which isn't pretty. */
. = ALIGN(32 / 8); . = ALIGN(32 / 8);
.preinit_array : { *(.preinit_array) } .preinit_array : { *(.preinit_array) }
.init_array : { *(.init_array) }
.fini_array : { *(.fini_array) } .fini_array : { *(.fini_array) }
.data : { .data : {
INIT_TASK_DATA(KERNEL_STACK_SIZE) INIT_TASK_DATA(KERNEL_STACK_SIZE)

View File

@ -48,7 +48,6 @@ config CC_DISABLE_WARN_MAYBE_UNINITIALIZED
config CONSTRUCTORS config CONSTRUCTORS
bool bool
depends on !UML
config IRQ_WORK config IRQ_WORK
bool bool

View File

@ -4,7 +4,7 @@ menu "GCOV-based kernel profiling"
config GCOV_KERNEL config GCOV_KERNEL
bool "Enable gcov-based kernel profiling" bool "Enable gcov-based kernel profiling"
depends on DEBUG_FS depends on DEBUG_FS
select CONSTRUCTORS if !UML select CONSTRUCTORS
default n default n
---help--- ---help---
This option enables gcov-based code profiling (e.g. for code coverage This option enables gcov-based code profiling (e.g. for code coverage