xref: /linux/arch/arm64/kernel/pi/Makefile (revision 68c76ad4a9571a2b603665c85cf8229bcf04982a)
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) \
6aacd149bSArd Biesheuvel		   $(call cc-option,-mbranch-protection=none) \
7aacd149bSArd Biesheuvel		   -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
8aacd149bSArd Biesheuvel		   -include $(srctree)/include/linux/hidden.h \
9aacd149bSArd Biesheuvel		   -D__DISABLE_EXPORTS -ffreestanding -D__NO_FORTIFY \
10*68c76ad4SArd Biesheuvel		   -fno-asynchronous-unwind-tables -fno-unwind-tables \
11aacd149bSArd Biesheuvel		   $(call cc-option,-fno-addrsig)
12aacd149bSArd Biesheuvel
13aacd149bSArd Biesheuvel# remove SCS flags from all objects in this directory
14aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
15aacd149bSArd Biesheuvel# disable LTO
16aacd149bSArd BiesheuvelKBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
17aacd149bSArd Biesheuvel
18aacd149bSArd BiesheuvelGCOV_PROFILE	:= n
19aacd149bSArd BiesheuvelKASAN_SANITIZE	:= n
20aacd149bSArd BiesheuvelKCSAN_SANITIZE	:= n
21aacd149bSArd BiesheuvelUBSAN_SANITIZE	:= n
22aacd149bSArd BiesheuvelKCOV_INSTRUMENT	:= n
23aacd149bSArd Biesheuvel
24aacd149bSArd Biesheuvel$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ \
25aacd149bSArd Biesheuvel			       --remove-section=.note.gnu.property \
26aacd149bSArd Biesheuvel			       --prefix-alloc-sections=.init
27aacd149bSArd Biesheuvel$(obj)/%.pi.o: $(obj)/%.o FORCE
28aacd149bSArd Biesheuvel	$(call if_changed,objcopy)
29aacd149bSArd Biesheuvel
30aacd149bSArd Biesheuvel$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
31aacd149bSArd Biesheuvel	$(call if_changed_rule,cc_o_c)
32aacd149bSArd Biesheuvel
33aacd149bSArd Biesheuvelobj-y		:= kaslr_early.pi.o lib-fdt.pi.o lib-fdt_ro.pi.o
34aacd149bSArd Biesheuvelextra-y		:= $(patsubst %.pi.o,%.o,$(obj-y))
35