xref: /linux/arch/arm64/kernel/pi/Makefile (revision 48157aa39286b8eddfb81eeaab4d64d0231450e7)
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
14aacd149bSArd Biesheuvel# remove SCS flags from all objects in this directory
15aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
16aacd149bSArd Biesheuvel# disable LTO
17aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
18aacd149bSArd Biesheuvel
19aacd149bSArd BiesheuvelGCOV_PROFILE	:= n
20aacd149bSArd BiesheuvelKASAN_SANITIZE	:= n
21aacd149bSArd BiesheuvelKCSAN_SANITIZE	:= n
22aacd149bSArd BiesheuvelUBSAN_SANITIZE	:= n
23aacd149bSArd BiesheuvelKCOV_INSTRUMENT	:= n
24aacd149bSArd Biesheuvel
25*48157aa3SArd Biesheuvelhostprogs	:= relacheck
26*48157aa3SArd Biesheuvel
27*48157aa3SArd Biesheuvelquiet_cmd_piobjcopy = $(quiet_cmd_objcopy)
28*48157aa3SArd Biesheuvel      cmd_piobjcopy = $(cmd_objcopy) && $(obj)/relacheck $(@) $(<)
29*48157aa3SArd Biesheuvel
30aacd149bSArd Biesheuvel$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ \
31aacd149bSArd Biesheuvel			       --remove-section=.note.gnu.property \
32aacd149bSArd Biesheuvel			       --prefix-alloc-sections=.init
33*48157aa3SArd Biesheuvel$(obj)/%.pi.o: $(obj)/%.o $(obj)/relacheck FORCE
34*48157aa3SArd Biesheuvel	$(call if_changed,piobjcopy)
35aacd149bSArd Biesheuvel
36aacd149bSArd Biesheuvel$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
37aacd149bSArd Biesheuvel	$(call if_changed_rule,cc_o_c)
38aacd149bSArd Biesheuvel
39aacd149bSArd Biesheuvelobj-y		:= kaslr_early.pi.o lib-fdt.pi.o lib-fdt_ro.pi.o
40aacd149bSArd Biesheuvelextra-y		:= $(patsubst %.pi.o,%.o,$(obj-y))
41