xref: /linux/arch/arm64/kernel/pi/Makefile (revision 84b04d3e6bdbc7551e62b75dd97cae4a8bddb1b6)
1aacd149bSArd Biesheuvel# SPDX-License-Identifier: GPL-2.0
2aacd149bSArd Biesheuvel# Copyright 2022 Google LLC
3aacd149bSArd Biesheuvel
4aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
5aacd149bSArd Biesheuvel		   -Os -DDISABLE_BRANCH_PROFILING $(DISABLE_STACKLEAK_PLUGIN) \
63dfdc275SArd Biesheuvel		   $(DISABLE_LATENT_ENTROPY_PLUGIN) \
7aacd149bSArd Biesheuvel		   $(call cc-option,-mbranch-protection=none) \
8aacd149bSArd Biesheuvel		   -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
9aacd149bSArd Biesheuvel		   -include $(srctree)/include/linux/hidden.h \
10aacd149bSArd Biesheuvel		   -D__DISABLE_EXPORTS -ffreestanding -D__NO_FORTIFY \
1168c76ad4SArd Biesheuvel		   -fno-asynchronous-unwind-tables -fno-unwind-tables \
12aacd149bSArd Biesheuvel		   $(call cc-option,-fno-addrsig)
13aacd149bSArd Biesheuvel
14*84b04d3eSArd Biesheuvel# this code may run with the MMU off so disable unaligned accesses
15*84b04d3eSArd BiesheuvelCFLAGS_map_range.o += -mstrict-align
16*84b04d3eSArd Biesheuvel
17aacd149bSArd Biesheuvel# remove SCS flags from all objects in this directory
18aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
19aacd149bSArd Biesheuvel# disable LTO
20aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
21aacd149bSArd Biesheuvel
22aacd149bSArd BiesheuvelGCOV_PROFILE	:= n
23aacd149bSArd BiesheuvelKASAN_SANITIZE	:= n
24aacd149bSArd BiesheuvelKCSAN_SANITIZE	:= n
25aacd149bSArd BiesheuvelUBSAN_SANITIZE	:= n
26aacd149bSArd BiesheuvelKCOV_INSTRUMENT	:= n
27aacd149bSArd Biesheuvel
2848157aa3SArd Biesheuvelhostprogs	:= relacheck
2948157aa3SArd Biesheuvel
3048157aa3SArd Biesheuvelquiet_cmd_piobjcopy = $(quiet_cmd_objcopy)
3148157aa3SArd Biesheuvel      cmd_piobjcopy = $(cmd_objcopy) && $(obj)/relacheck $(@) $(<)
3248157aa3SArd Biesheuvel
33aacd149bSArd Biesheuvel$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ \
34a86aa72eSArd Biesheuvel			       --remove-section=.note.gnu.property
3548157aa3SArd Biesheuvel$(obj)/%.pi.o: $(obj)/%.o $(obj)/relacheck FORCE
3648157aa3SArd Biesheuvel	$(call if_changed,piobjcopy)
37aacd149bSArd Biesheuvel
38a86aa72eSArd Biesheuvel# ensure that all the lib- code ends up as __init code and data
39a86aa72eSArd Biesheuvel$(obj)/lib-%.pi.o: OBJCOPYFLAGS += --prefix-alloc-sections=.init
40a86aa72eSArd Biesheuvel
41aacd149bSArd Biesheuvel$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
42aacd149bSArd Biesheuvel	$(call if_changed_rule,cc_o_c)
43aacd149bSArd Biesheuvel
448a6e40e1SArd Biesheuvelobj-y					:= idreg-override.pi.o \
4597a6f43bSArd Biesheuvel					   map_kernel.pi.o map_range.pi.o \
468a6e40e1SArd Biesheuvel					   lib-fdt.pi.o lib-fdt_ro.pi.o
47e223a449SArd Biesheuvelobj-$(CONFIG_RELOCATABLE)		+= relocate.pi.o
48e223a449SArd Biesheuvelobj-$(CONFIG_RANDOMIZE_BASE)		+= kaslr_early.pi.o
498a6e40e1SArd Biesheuvelobj-$(CONFIG_UNWIND_PATCH_PAC_INTO_SCS)	+= patch-scs.pi.o
50aacd149bSArd Biesheuvelextra-y					:= $(patsubst %.pi.o,%.o,$(obj-y))
51