xref: /linux/arch/arm64/kernel/pi/Makefile (revision e223a449125571daa62debd8249fa4fc2da0a961)
1# SPDX-License-Identifier: GPL-2.0
2# Copyright 2022 Google LLC
3
4KBUILD_CFLAGS	:= $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
5		   -Os -DDISABLE_BRANCH_PROFILING $(DISABLE_STACKLEAK_PLUGIN) \
6		   $(DISABLE_LATENT_ENTROPY_PLUGIN) \
7		   $(call cc-option,-mbranch-protection=none) \
8		   -I$(srctree)/scripts/dtc/libfdt -fno-stack-protector \
9		   -include $(srctree)/include/linux/hidden.h \
10		   -D__DISABLE_EXPORTS -ffreestanding -D__NO_FORTIFY \
11		   -fno-asynchronous-unwind-tables -fno-unwind-tables \
12		   $(call cc-option,-fno-addrsig)
13
14# remove SCS flags from all objects in this directory
15KBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
16# disable LTO
17KBUILD_CFLAGS	:= $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
18
19GCOV_PROFILE	:= n
20KASAN_SANITIZE	:= n
21KCSAN_SANITIZE	:= n
22UBSAN_SANITIZE	:= n
23KCOV_INSTRUMENT	:= n
24
25hostprogs	:= relacheck
26
27quiet_cmd_piobjcopy = $(quiet_cmd_objcopy)
28      cmd_piobjcopy = $(cmd_objcopy) && $(obj)/relacheck $(@) $(<)
29
30$(obj)/%.pi.o: OBJCOPYFLAGS := --prefix-symbols=__pi_ \
31			       --remove-section=.note.gnu.property
32$(obj)/%.pi.o: $(obj)/%.o $(obj)/relacheck FORCE
33	$(call if_changed,piobjcopy)
34
35# ensure that all the lib- code ends up as __init code and data
36$(obj)/lib-%.pi.o: OBJCOPYFLAGS += --prefix-alloc-sections=.init
37
38$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
39	$(call if_changed_rule,cc_o_c)
40
41obj-y				:= idreg-override.pi.o lib-fdt.pi.o lib-fdt_ro.pi.o
42obj-$(CONFIG_RELOCATABLE)	+= relocate.pi.o
43obj-$(CONFIG_RANDOMIZE_BASE)	+= kaslr_early.pi.o
44extra-y				:= $(patsubst %.pi.o,%.o,$(obj-y))
45