Building the Linux kernel with -fsanitize=thread produces unwanted .eh_frame and .init_array.0 sections, even with -fno-unwind-tables and -fno-asynchronous-unwind-tables.
More details: https://lore.kernel.org/lkml/202006270840.E0BC752A72@keescook/
-fsanitize=kernel-address also causes this problem.
Related? https://reviews.llvm.org/D100251
The .eh_frame issue was fixed by https://reviews.llvm.org/D100251 (target: 13.0.0). For .init_array.0, -fsanitize={address,memory,thread,...} instrumentations create a module constructor which is placed in .init_array.0 . For memory/thread, the module constructor just calls an init function which is really small. For address, the module constructor needs to register global variables (even under -fsanitize=kernel-address), which cannot be simply ignored. It is likely that the kernel doesn't need .init_array.0 for memory/thread, but introducing a new option seems overkill to me. Ignoring it with the current /DISCARD/ : { ... *(.init_array.*) } works quite well.