Makefile (d729b554e17904e16498ab5c36122d70406f70ae) | Makefile (68c76ad4a9571a2b603665c85cf8229bcf04982a) |
---|---|
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# | 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# |
8 9# non-x86 reuses KBUILD_CFLAGS, x86 does not 10cflags-y := $(KBUILD_CFLAGS) 11 | |
12cflags-$(CONFIG_X86_32) := -march=i386 13cflags-$(CONFIG_X86_64) := -mcmodel=small 14cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \ 15 -fPIC -fno-strict-aliasing -mno-red-zone \ 16 -mno-mmx -mno-sse -fshort-wchar \ 17 -Wno-pointer-sign \ 18 $(call cc-disable-warning, address-of-packed-member) \ 19 $(call cc-disable-warning, gnu) \ 20 -fno-asynchronous-unwind-tables \ 21 $(CLANG_FLAGS) 22 23# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly 24# disable the stackleak plugin | 8cflags-$(CONFIG_X86_32) := -march=i386 9cflags-$(CONFIG_X86_64) := -mcmodel=small 10cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \ 11 -fPIC -fno-strict-aliasing -mno-red-zone \ 12 -mno-mmx -mno-sse -fshort-wchar \ 13 -Wno-pointer-sign \ 14 $(call cc-disable-warning, address-of-packed-member) \ 15 $(call cc-disable-warning, gnu) \ 16 -fno-asynchronous-unwind-tables \ 17 $(CLANG_FLAGS) 18 19# arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly 20# disable the stackleak plugin |
25cflags-$(CONFIG_ARM64) += -fpie $(DISABLE_STACKLEAK_PLUGIN) \ | 21cflags-$(CONFIG_ARM64) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ 22 -fpie $(DISABLE_STACKLEAK_PLUGIN) \ 23 -fno-unwind-tables -fno-asynchronous-unwind-tables \ |
26 $(call cc-option,-mbranch-protection=none) | 24 $(call cc-option,-mbranch-protection=none) |
27cflags-$(CONFIG_ARM) += -DEFI_HAVE_STRLEN -DEFI_HAVE_STRNLEN \ 28 -DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \ 29 -DEFI_HAVE_STRCMP -fno-builtin -fpic \ | 25cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ 26 -fno-builtin -fpic \ |
30 $(call cc-option,-mno-single-pic-base) | 27 $(call cc-option,-mno-single-pic-base) |
31cflags-$(CONFIG_RISCV) += -fpic 32cflags-$(CONFIG_LOONGARCH) += -fpie | 28cflags-$(CONFIG_RISCV) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ 29 -fpic 30cflags-$(CONFIG_LOONGARCH) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \ 31 -fpie |
33 34cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt 35 | 32 33cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt 34 |
36KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(cflags-y)) \ 37 -Os -DDISABLE_BRANCH_PROFILING \ | 35KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \ |
38 -include $(srctree)/include/linux/hidden.h \ 39 -D__NO_FORTIFY \ 40 -ffreestanding \ 41 -fno-stack-protector \ 42 $(call cc-option,-fno-addrsig) \ 43 -D__DISABLE_EXPORTS 44 45# --- 19 unchanged lines hidden (view full) --- 65OBJECT_FILES_NON_STANDARD := y 66 67# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 68KCOV_INSTRUMENT := n 69 70lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \ 71 file.o mem.o random.o randomalloc.o pci.o \ 72 skip_spaces.o lib-cmdline.o lib-ctype.o \ | 36 -include $(srctree)/include/linux/hidden.h \ 37 -D__NO_FORTIFY \ 38 -ffreestanding \ 39 -fno-stack-protector \ 40 $(call cc-option,-fno-addrsig) \ 41 -D__DISABLE_EXPORTS 42 43# --- 19 unchanged lines hidden (view full) --- 63OBJECT_FILES_NON_STANDARD := y 64 65# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 66KCOV_INSTRUMENT := n 67 68lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \ 69 file.o mem.o random.o randomalloc.o pci.o \ 70 skip_spaces.o lib-cmdline.o lib-ctype.o \ |
73 alignedmem.o relocate.o printk.o vsprintf.o | 71 alignedmem.o relocate.o vsprintf.o |
74 75# include the stub's libfdt dependencies from lib/ when needed 76libfdt-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c \ 77 fdt_empty_tree.c fdt_sw.c 78 79lib-$(CONFIG_EFI_PARAMS_FROM_FDT) += fdt.o \ 80 $(patsubst %.c,lib-%.o,$(libfdt-deps)) 81 82$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE 83 $(call if_changed_rule,cc_o_c) 84 | 72 73# include the stub's libfdt dependencies from lib/ when needed 74libfdt-deps := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c \ 75 fdt_empty_tree.c fdt_sw.c 76 77lib-$(CONFIG_EFI_PARAMS_FROM_FDT) += fdt.o \ 78 $(patsubst %.c,lib-%.o,$(libfdt-deps)) 79 80$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE 81 $(call if_changed_rule,cc_o_c) 82 |
85lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o \ 86 screen_info.o efi-stub-entry.o | 83lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o |
87 88lib-$(CONFIG_ARM) += arm32-stub.o | 84 85lib-$(CONFIG_ARM) += arm32-stub.o |
89lib-$(CONFIG_ARM64) += arm64.o arm64-stub.o arm64-entry.o | 86lib-$(CONFIG_ARM64) += arm64-stub.o |
90lib-$(CONFIG_X86) += x86-stub.o | 87lib-$(CONFIG_X86) += x86-stub.o |
91lib-$(CONFIG_RISCV) += riscv.o riscv-stub.o 92lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o | 88lib-$(CONFIG_RISCV) += riscv-stub.o 89lib-$(CONFIG_LOONGARCH) += loongarch-stub.o |
93 94CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 95 96zboot-obj-$(CONFIG_RISCV) := lib-clz_ctz.o lib-ashldi3.o 97lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y) 98 99extra-y := $(lib-y) 100lib-y := $(patsubst %.o,%.stub.o,$(lib-y)) --- 34 unchanged lines hidden (view full) --- 135# not rely on any absolute symbol references, considering that the virtual 136# kernel mapping that the linker uses is not active yet when the stub is 137# executing. So build all C dependencies of the EFI stub into libstub, and do 138# a verification pass to see if any absolute relocations exist in any of the 139# object files. 140# 141STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \ 142 --prefix-symbols=__efistub_ | 90 91CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 92 93zboot-obj-$(CONFIG_RISCV) := lib-clz_ctz.o lib-ashldi3.o 94lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y) 95 96extra-y := $(lib-y) 97lib-y := $(patsubst %.o,%.stub.o,$(lib-y)) --- 34 unchanged lines hidden (view full) --- 132# not rely on any absolute symbol references, considering that the virtual 133# kernel mapping that the linker uses is not active yet when the stub is 134# executing. So build all C dependencies of the EFI stub into libstub, and do 135# a verification pass to see if any absolute relocations exist in any of the 136# object files. 137# 138STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \ 139 --prefix-symbols=__efistub_ |
143STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS64 | 140STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS |
144 145# For RISC-V, we don't need anything special other than arm64. Keep all the 146# symbols in .init section and make sure that no absolute symbols references 147# doesn't exist. 148STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \ 149 --prefix-symbols=__efistub_ 150STUBCOPY_RELOC-$(CONFIG_RISCV) := R_RISCV_HI20 151 --- 23 unchanged lines hidden --- | 141 142# For RISC-V, we don't need anything special other than arm64. Keep all the 143# symbols in .init section and make sure that no absolute symbols references 144# doesn't exist. 145STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \ 146 --prefix-symbols=__efistub_ 147STUBCOPY_RELOC-$(CONFIG_RISCV) := R_RISCV_HI20 148 --- 23 unchanged lines hidden --- |