mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-30 13:03:01 +00:00

objtool already struggles to identify jump tables correctly in non-PIC code, where the idiom is something like jmpq *table(,%idx,8) and the table is a list of absolute addresses of jump targets. When using -fPIC, both the table reference as well as the jump targets are emitted in a RIP-relative manner, resulting in something like leaq table(%rip), %tbl movslq (%tbl,%idx,4), %offset addq %offset, %tbl jmpq *%tbl and the table is a list of offsets of the jump targets relative to the start of the entire table. Considering that this sequence of instructions can be interleaved with other instructions that have nothing to do with the jump table in question, it is extremely difficult to infer the control flow by deriving the jump targets from the indirect jump, the location of the table and the relative offsets it contains. So let's not bother and disable jump tables for code built with -fPIC under arch/x86/boot/startup. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linux-efi@vger.kernel.org Link: https://lore.kernel.org/r/20250422210510.600354-2-ardb+git@google.com
31 lines
980 B
Makefile
31 lines
980 B
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
KBUILD_AFLAGS += -D__DISABLE_EXPORTS
|
|
KBUILD_CFLAGS += -D__DISABLE_EXPORTS -mcmodel=small -fPIC \
|
|
-Os -DDISABLE_BRANCH_PROFILING \
|
|
$(DISABLE_STACKLEAK_PLUGIN) \
|
|
-fno-stack-protector -D__NO_FORTIFY \
|
|
-fno-jump-tables \
|
|
-include $(srctree)/include/linux/hidden.h
|
|
|
|
# disable ftrace hooks and LTO
|
|
KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS))
|
|
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS))
|
|
KASAN_SANITIZE := n
|
|
KCSAN_SANITIZE := n
|
|
KMSAN_SANITIZE := n
|
|
UBSAN_SANITIZE := n
|
|
KCOV_INSTRUMENT := n
|
|
|
|
obj-$(CONFIG_X86_64) += gdt_idt.o map_kernel.o
|
|
obj-$(CONFIG_AMD_MEM_ENCRYPT) += sme.o sev-startup.o
|
|
|
|
lib-$(CONFIG_X86_64) += la57toggle.o
|
|
lib-$(CONFIG_EFI_MIXED) += efi-mixed.o
|
|
|
|
#
|
|
# Disable objtool validation for all library code, which is intended
|
|
# to be linked into the decompressor or the EFI stub but not vmlinux
|
|
#
|
|
$(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STANDARD := y
|