xref: /openbmc/linux/drivers/firmware/efi/libstub/Makefile (revision ddeeefe2dfbe1fa6b116b9362b1bec465b64c873)
1f4f75ad5SArd Biesheuvel#
2f4f75ad5SArd Biesheuvel# The stub may be linked into the kernel proper or into a separate boot binary,
3f4f75ad5SArd Biesheuvel# but in either case, it executes before the kernel does (with MMU disabled) so
4f4f75ad5SArd Biesheuvel# things like ftrace and stack-protector are likely to cause trouble if left
5f4f75ad5SArd Biesheuvel# enabled, even if doing so doesn't break the build.
6f4f75ad5SArd Biesheuvel#
7f4f75ad5SArd Biesheuvelcflags-$(CONFIG_X86_32)		:= -march=i386
8f4f75ad5SArd Biesheuvelcflags-$(CONFIG_X86_64)		:= -mcmodel=small
9f4f75ad5SArd Biesheuvelcflags-$(CONFIG_X86)		+= -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
10f4f75ad5SArd Biesheuvel				   -fPIC -fno-strict-aliasing -mno-red-zone \
11f4f75ad5SArd Biesheuvel				   -mno-mmx -mno-sse -DDISABLE_BRANCH_PROFILING
12f4f75ad5SArd Biesheuvel
13f4f75ad5SArd Biesheuvelcflags-$(CONFIG_ARM64)		:= $(subst -pg,,$(KBUILD_CFLAGS))
14f4f75ad5SArd Biesheuvelcflags-$(CONFIG_ARM)		:= $(subst -pg,,$(KBUILD_CFLAGS)) \
15f4f75ad5SArd Biesheuvel				   -fno-builtin -fpic -mno-single-pic-base
16f4f75ad5SArd Biesheuvel
17f4f75ad5SArd BiesheuvelKBUILD_CFLAGS			:= $(cflags-y) \
18f4f75ad5SArd Biesheuvel				   $(call cc-option,-ffreestanding) \
19f4f75ad5SArd Biesheuvel				   $(call cc-option,-fno-stack-protector)
20f4f75ad5SArd Biesheuvel
21f4f75ad5SArd BiesheuvelGCOV_PROFILE			:= n
22f4f75ad5SArd Biesheuvel
23f4f75ad5SArd Biesheuvellib-y				:= efi-stub-helper.o
24f4f75ad5SArd Biesheuvellib-$(CONFIG_EFI_ARMSTUB)	+= arm-stub.o fdt.o
25f4f75ad5SArd Biesheuvel
26f4f75ad5SArd BiesheuvelCFLAGS_fdt.o			+= -I$(srctree)/scripts/dtc/libfdt/
27*ddeeefe2SArd Biesheuvel
28*ddeeefe2SArd Biesheuvel#
29*ddeeefe2SArd Biesheuvel# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
30*ddeeefe2SArd Biesheuvel# code indefinitely unless it is annotated as __init/__initdata/__initconst etc.
31*ddeeefe2SArd Biesheuvel# So let's apply the __init annotations at the section level, by prefixing
32*ddeeefe2SArd Biesheuvel# the section names directly. This will ensure that even all the inline string
33*ddeeefe2SArd Biesheuvel# literals are covered.
34*ddeeefe2SArd Biesheuvel#
35*ddeeefe2SArd Biesheuvelextra-$(CONFIG_ARM64)		:= $(lib-y)
36*ddeeefe2SArd Biesheuvellib-$(CONFIG_ARM64)		:= $(patsubst %.o,%.init.o,$(lib-y))
37*ddeeefe2SArd Biesheuvel
38*ddeeefe2SArd BiesheuvelOBJCOPYFLAGS := --prefix-alloc-sections=.init
39*ddeeefe2SArd Biesheuvel$(obj)/%.init.o: $(obj)/%.o FORCE
40*ddeeefe2SArd Biesheuvel	$(call if_changed,objcopy)
41