15a67da1fSArd Biesheuvel# SPDX-License-Identifier: GPL-2.0 25a67da1fSArd Biesheuvel 34f2d1bbcSArd BiesheuvelKBUILD_AFLAGS += -D__DISABLE_EXPORTS 44cecebf2SArd BiesheuvelKBUILD_CFLAGS += -D__DISABLE_EXPORTS -mcmodel=small -fPIC \ 54cecebf2SArd Biesheuvel -Os -DDISABLE_BRANCH_PROFILING \ 64cecebf2SArd Biesheuvel $(DISABLE_STACKLEAK_PLUGIN) \ 7*7b38dec3SArd Biesheuvel $(DISABLE_LATENT_ENTROPY_PLUGIN) \ 84cecebf2SArd Biesheuvel -fno-stack-protector -D__NO_FORTIFY \ 9121c335bSArd Biesheuvel -fno-jump-tables \ 104cecebf2SArd Biesheuvel -include $(srctree)/include/linux/hidden.h 114cecebf2SArd Biesheuvel 12498cb872SNathan Chancellor# disable ftrace hooks and LTO 134cecebf2SArd BiesheuvelKBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) 14498cb872SNathan ChancellorKBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS)) 154cecebf2SArd BiesheuvelKASAN_SANITIZE := n 164cecebf2SArd BiesheuvelKCSAN_SANITIZE := n 174cecebf2SArd BiesheuvelKMSAN_SANITIZE := n 184cecebf2SArd BiesheuvelUBSAN_SANITIZE := n 194cecebf2SArd BiesheuvelKCOV_INSTRUMENT := n 204cecebf2SArd Biesheuvel 21dbe0ad77SArd Biesheuvelobj-$(CONFIG_X86_64) += gdt_idt.o map_kernel.o 22a3cbbb47SArd Biesheuvelobj-$(CONFIG_AMD_MEM_ENCRYPT) += sme.o sev-startup.o 23296650c8SArd Biesheuvelpi-objs := $(patsubst %.o,$(obj)/%.o,$(obj-y)) 244f2d1bbcSArd Biesheuvel 255a67da1fSArd Biesheuvellib-$(CONFIG_X86_64) += la57toggle.o 264f2d1bbcSArd Biesheuvellib-$(CONFIG_EFI_MIXED) += efi-mixed.o 27d9fa398fSArd Biesheuvel 28d9fa398fSArd Biesheuvel# 29d9fa398fSArd Biesheuvel# Disable objtool validation for all library code, which is intended 30d9fa398fSArd Biesheuvel# to be linked into the decompressor or the EFI stub but not vmlinux 31d9fa398fSArd Biesheuvel# 32d9fa398fSArd Biesheuvel$(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STANDARD := y 33296650c8SArd Biesheuvel 34296650c8SArd Biesheuvel# 35296650c8SArd Biesheuvel# Invoke objtool for each object individually to check for absolute 36296650c8SArd Biesheuvel# relocations, even if other objtool actions are being deferred. 37296650c8SArd Biesheuvel# 38296650c8SArd Biesheuvel$(pi-objs): objtool-enabled = 1 39296650c8SArd Biesheuvel$(pi-objs): objtool-args = $(if $(delay-objtool),,$(objtool-args-y)) --noabs 40*7b38dec3SArd Biesheuvel 41*7b38dec3SArd Biesheuvel# 42*7b38dec3SArd Biesheuvel# Confine the startup code by prefixing all symbols with __pi_ (for position 43*7b38dec3SArd Biesheuvel# independent). This ensures that startup code can only call other startup 44*7b38dec3SArd Biesheuvel# code, or code that has explicitly been made accessible to it via a symbol 45*7b38dec3SArd Biesheuvel# alias. 46*7b38dec3SArd Biesheuvel# 47*7b38dec3SArd Biesheuvel$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ 48*7b38dec3SArd Biesheuvel$(obj)/%.pi.o: $(obj)/%.o FORCE 49*7b38dec3SArd Biesheuvel $(call if_changed,objcopy) 50*7b38dec3SArd Biesheuvel 51*7b38dec3SArd Biesheuveltargets += $(obj-y) 52*7b38dec3SArd Biesheuvelobj-y := $(patsubst %.o,%.pi.o,$(obj-y)) 53