| 1 |
# SPDX-License-Identifier: GPL-2.0 |
| 2 |
|
| 3 |
KBUILD_AFLAGS += -D__DISABLE_EXPORTS |
| 4 |
KBUILD_CFLAGS += -D__DISABLE_EXPORTS -mcmodel=small -fPIC \ |
| 5 |
-Os -DDISABLE_BRANCH_PROFILING \ |
| 6 |
$(DISABLE_STACKLEAK_PLUGIN) \ |
| 7 |
$(DISABLE_LATENT_ENTROPY_PLUGIN) \ |
| 8 |
-fno-stack-protector -D__NO_FORTIFY \ |
| 9 |
-fno-jump-tables \ |
| 10 |
-include $(srctree)/include/linux/hidden.h |
| 11 |
|
| 12 |
# disable ftrace hooks and LTO |
| 13 |
KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) |
| 14 |
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS)) |
| 15 |
KASAN_SANITIZE := n |
| 16 |
KCSAN_SANITIZE := n |
| 17 |
KMSAN_SANITIZE := n |
| 18 |
UBSAN_SANITIZE := n |
| 19 |
KCOV_INSTRUMENT := n |
| 20 |
|
| 21 |
obj-$(CONFIG_X86_64) += gdt_idt.o map_kernel.o |
| 22 |
obj-$(CONFIG_AMD_MEM_ENCRYPT) += sme.o sev-startup.o |
| 23 |
pi-objs := $(patsubst %.o,$(obj)/%.o,$(obj-y)) |
| 24 |
|
| 25 |
lib-$(CONFIG_X86_64) += la57toggle.o |
| 26 |
lib-$(CONFIG_EFI_MIXED) += efi-mixed.o |
| 27 |
|
| 28 |
# |
| 29 |
# Disable objtool validation for all library code, which is intended |
| 30 |
# to be linked into the decompressor or the EFI stub but not vmlinux |
| 31 |
# |
| 32 |
$(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STANDARD := y |
| 33 |
|
| 34 |
# |
| 35 |
# Invoke objtool for each object individually to check for absolute |
| 36 |
# relocations, even if other objtool actions are being deferred. |
| 37 |
# |
| 38 |
$(pi-objs): objtool-enabled = 1 |
| 39 |
$(pi-objs): objtool-args = $(if $(delay-objtool),--dry-run,$(objtool-args-y)) --noabs |
| 40 |
|
| 41 |
# |
| 42 |
# Confine the startup code by prefixing all symbols with __pi_ (for position |
| 43 |
# independent). This ensures that startup code can only call other startup |
| 44 |
# code, or code that has explicitly been made accessible to it via a symbol |
| 45 |
# alias. |
| 46 |
# |
| 47 |
$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ |
| 48 |
$(obj)/%.pi.o: $(obj)/%.o FORCE |
| 49 |
$(call if_changed,objcopy) |
| 50 |
|
| 51 |
targets += $(obj-y) |
| 52 |
obj-y := $(patsubst %.o,%.pi.o,$(obj-y)) |