Skip to content

Commit

Permalink
kcsan: select CONFIG_CONSTRUCTORS
Browse files Browse the repository at this point in the history
Building a kcsan enabled kernel for x86_64 with gcc-11 results in a lot
of build warnings or errors without CONFIG_CONSTRUCTORS:

x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/copy_mc.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/cpu.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-partial_64.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-wrappers_64.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn-eval.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn.o'
x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/misc.o'

The same thing has been reported for mips64. I can't reproduce it for
any other compiler version, so I don't know if constructors are always
required here or if this is a gcc-11 specific implementation detail.

I see no harm in always enabling constructors here, and this reliably
fixes the build warnings for me.

Link: https://lore.kernel.org/lkml/[email protected]/T/
Cc: Kees Cook <[email protected]>
See-also: 3e66314 ("vmlinux.lds.h: Keep .ctors.* with .ctors")
Signed-off-by: Arnd Bergmann <[email protected]>
Reviewed-by: Marco Elver <[email protected]>
Signed-off-by: Paul E. McKenney <[email protected]>
  • Loading branch information
arndb authored and paulmckrcu committed Feb 22, 2023
1 parent 1b929c0 commit 6ba912f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/Kconfig.kcsan
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ menuconfig KCSAN
bool "KCSAN: dynamic data race detector"
depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER
depends on DEBUG_KERNEL && !KASAN
select CONSTRUCTORS
select STACKTRACE
help
The Kernel Concurrency Sanitizer (KCSAN) is a dynamic
Expand Down

0 comments on commit 6ba912f

Please sign in to comment.