Makefile (57b8b1b4351dafe94de09a2aab5eba885b6705f0) Makefile (d7071743db31b4f6898b1c742e4b451bb4bc4b02)
1# SPDX-License-Identifier: GPL-2.0
2#
3# The stub may be linked into the kernel proper or into a separate boot binary,
4# but in either case, it executes before the kernel does (with MMU disabled) so
5# things like ftrace and stack-protector are likely to cause trouble if left
6# enabled, even if doing so doesn't break the build.
7#
8cflags-$(CONFIG_X86_32) := -march=i386

--- 8 unchanged lines hidden (view full) ---

17
18# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly
19# disable the stackleak plugin
20cflags-$(CONFIG_ARM64) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
21 -fpie $(DISABLE_STACKLEAK_PLUGIN)
22cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
23 -fno-builtin -fpic \
24 $(call cc-option,-mno-single-pic-base)
1# SPDX-License-Identifier: GPL-2.0
2#
3# The stub may be linked into the kernel proper or into a separate boot binary,
4# but in either case, it executes before the kernel does (with MMU disabled) so
5# things like ftrace and stack-protector are likely to cause trouble if left
6# enabled, even if doing so doesn't break the build.
7#
8cflags-$(CONFIG_X86_32) := -march=i386

--- 8 unchanged lines hidden (view full) ---

17
18# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly
19# disable the stackleak plugin
20cflags-$(CONFIG_ARM64) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
21 -fpie $(DISABLE_STACKLEAK_PLUGIN)
22cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
23 -fno-builtin -fpic \
24 $(call cc-option,-mno-single-pic-base)
25cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
26 -fpic
25
26cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
27
28KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
29 -include $(srctree)/drivers/firmware/efi/libstub/hidden.h \
30 -D__NO_FORTIFY \
31 -ffreestanding \
32 -fno-stack-protector \

--- 25 unchanged lines hidden (view full) ---

58 $(call if_changed_rule,cc_o_c)
59
60lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o fdt.o string.o \
61 $(patsubst %.c,lib-%.o,$(efi-deps-y))
62
63lib-$(CONFIG_ARM) += arm32-stub.o
64lib-$(CONFIG_ARM64) += arm64-stub.o
65lib-$(CONFIG_X86) += x86-stub.o
27
28cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
29
30KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
31 -include $(srctree)/drivers/firmware/efi/libstub/hidden.h \
32 -D__NO_FORTIFY \
33 -ffreestanding \
34 -fno-stack-protector \

--- 25 unchanged lines hidden (view full) ---

60 $(call if_changed_rule,cc_o_c)
61
62lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o fdt.o string.o \
63 $(patsubst %.c,lib-%.o,$(efi-deps-y))
64
65lib-$(CONFIG_ARM) += arm32-stub.o
66lib-$(CONFIG_ARM64) += arm64-stub.o
67lib-$(CONFIG_X86) += x86-stub.o
68lib-$(CONFIG_RISCV) += riscv-stub.o
66CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
69CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
70CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
67
68#
69# For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
70# .bss section, so the .bss section of the EFI stub needs to be included in the
71# .data section of the compressed kernel to ensure initialization. Rename the
72# .bss section here so it's easy to pick out in the linker script.
73#
74STUBCOPY_FLAGS-$(CONFIG_X86) += --rename-section .bss=.bss.efistub,load,alloc

--- 25 unchanged lines hidden (view full) ---

100#
101extra-y := $(lib-y)
102lib-y := $(patsubst %.o,%.stub.o,$(lib-y))
103
104STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
105 --prefix-symbols=__efistub_
106STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
107
71
72#
73# For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the
74# .bss section, so the .bss section of the EFI stub needs to be included in the
75# .data section of the compressed kernel to ensure initialization. Rename the
76# .bss section here so it's easy to pick out in the linker script.
77#
78STUBCOPY_FLAGS-$(CONFIG_X86) += --rename-section .bss=.bss.efistub,load,alloc

--- 25 unchanged lines hidden (view full) ---

104#
105extra-y := $(lib-y)
106lib-y := $(patsubst %.o,%.stub.o,$(lib-y))
107
108STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
109 --prefix-symbols=__efistub_
110STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
111
112# For RISC-V, we don't need anything special other than arm64. Keep all the
113# symbols in .init section and make sure that no absolute symbols references
114# doesn't exist.
115STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \
116 --prefix-symbols=__efistub_
117STUBCOPY_RELOC-$(CONFIG_RISCV) := R_RISCV_HI20
118
108$(obj)/%.stub.o: $(obj)/%.o FORCE
109 $(call if_changed,stubcopy)
110
111#
112# Strip debug sections and some other sections that may legally contain
113# absolute relocations, so that we can inspect the remaining sections for
114# such relocations. If none are found, regenerate the output object, but
115# this time, use objcopy and leave all sections in place.
116#
117quiet_cmd_stubcopy = STUBCPY $@
118 cmd_stubcopy = \
119 $(STRIP) --strip-debug -o $@ $<; \
120 if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
121 echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
122 /bin/false; \
123 fi; \
124 $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
119$(obj)/%.stub.o: $(obj)/%.o FORCE
120 $(call if_changed,stubcopy)
121
122#
123# Strip debug sections and some other sections that may legally contain
124# absolute relocations, so that we can inspect the remaining sections for
125# such relocations. If none are found, regenerate the output object, but
126# this time, use objcopy and leave all sections in place.
127#
128quiet_cmd_stubcopy = STUBCPY $@
129 cmd_stubcopy = \
130 $(STRIP) --strip-debug -o $@ $<; \
131 if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then \
132 echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
133 /bin/false; \
134 fi; \
135 $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@