.. | .. |
---|
17 | 17 | # (see scripts/Makefile.lib size_append) |
---|
18 | 18 | # compressed vmlinux.bin.all + u32 size of vmlinux.bin.all |
---|
19 | 19 | |
---|
| 20 | +# Sanitizer runtimes are unavailable and cannot be linked for early boot code. |
---|
20 | 21 | KASAN_SANITIZE := n |
---|
| 22 | +KCSAN_SANITIZE := n |
---|
21 | 23 | OBJECT_FILES_NON_STANDARD := y |
---|
22 | 24 | |
---|
23 | 25 | # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. |
---|
24 | 26 | KCOV_INSTRUMENT := n |
---|
25 | 27 | |
---|
26 | 28 | targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ |
---|
27 | | - vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 |
---|
| 29 | + vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst |
---|
28 | 30 | |
---|
29 | | -KBUILD_CFLAGS := -m$(BITS) -O2 |
---|
30 | | -KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC) |
---|
| 31 | +# CLANG_FLAGS must come before any cc-disable-warning or cc-option calls in |
---|
| 32 | +# case of cross compiling, as it has the '--target=' flag, which is needed to |
---|
| 33 | +# avoid errors with '-march=i386', and future flags may depend on the target to |
---|
| 34 | +# be valid. |
---|
| 35 | +KBUILD_CFLAGS := -m$(BITS) -O2 $(CLANG_FLAGS) |
---|
| 36 | +KBUILD_CFLAGS += -fno-strict-aliasing -fPIE |
---|
31 | 37 | KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING |
---|
32 | 38 | cflags-$(CONFIG_X86_32) := -march=i386 |
---|
33 | | -cflags-$(CONFIG_X86_64) := -mcmodel=small |
---|
| 39 | +cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone |
---|
34 | 40 | KBUILD_CFLAGS += $(cflags-y) |
---|
35 | 41 | KBUILD_CFLAGS += -mno-mmx -mno-sse |
---|
36 | | -KBUILD_CFLAGS += $(call cc-option,-ffreestanding) |
---|
37 | | -KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) |
---|
| 42 | +KBUILD_CFLAGS += -ffreestanding |
---|
| 43 | +KBUILD_CFLAGS += -fno-stack-protector |
---|
38 | 44 | KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) |
---|
39 | 45 | KBUILD_CFLAGS += $(call cc-disable-warning, gnu) |
---|
40 | 46 | KBUILD_CFLAGS += -Wno-pointer-sign |
---|
| 47 | +KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) |
---|
| 48 | +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables |
---|
| 49 | +KBUILD_CFLAGS += -D__DISABLE_EXPORTS |
---|
41 | 50 | # Disable relocation relaxation in case the link is not PIE. |
---|
42 | 51 | KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no) |
---|
| 52 | +KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h |
---|
| 53 | + |
---|
| 54 | +# sev-es.c indirectly inludes inat-table.h which is generated during |
---|
| 55 | +# compilation and stored in $(objtree). Add the directory to the includes so |
---|
| 56 | +# that the compiler finds it even with out-of-tree builds (make O=/some/path). |
---|
| 57 | +CFLAGS_sev-es.o += -I$(objtree)/arch/x86/lib/ |
---|
43 | 58 | |
---|
44 | 59 | KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ |
---|
45 | 60 | GCOV_PROFILE := n |
---|
46 | 61 | UBSAN_SANITIZE :=n |
---|
47 | 62 | |
---|
48 | 63 | KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) |
---|
| 64 | +KBUILD_LDFLAGS += $(call ld-option,--no-ld-generated-unwind-info) |
---|
49 | 65 | # Compressed kernel should be built as PIE since it may be loaded at any |
---|
50 | 66 | # address by the bootloader. |
---|
51 | | -ifeq ($(CONFIG_X86_32),y) |
---|
52 | | -KBUILD_LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker) |
---|
53 | | -else |
---|
54 | | -# To build 64-bit compressed kernel as PIE, we disable relocation |
---|
55 | | -# overflow check to avoid relocation overflow error with a new linker |
---|
56 | | -# command-line option, -z noreloc-overflow. |
---|
57 | | -KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ |
---|
58 | | - && echo "-z noreloc-overflow -pie --no-dynamic-linker") |
---|
| 67 | +LDFLAGS_vmlinux := -pie $(call ld-option, --no-dynamic-linker) |
---|
| 68 | +ifdef CONFIG_LD_ORPHAN_WARN |
---|
| 69 | +LDFLAGS_vmlinux += --orphan-handling=warn |
---|
59 | 70 | endif |
---|
60 | | -LDFLAGS_vmlinux := -T |
---|
| 71 | +LDFLAGS_vmlinux += -z noexecstack |
---|
| 72 | +LDFLAGS_vmlinux += $(call ld-option,--no-warn-rwx-segments) |
---|
| 73 | +LDFLAGS_vmlinux += -T |
---|
61 | 74 | |
---|
62 | | -hostprogs-y := mkpiggy |
---|
| 75 | +hostprogs := mkpiggy |
---|
63 | 76 | HOST_EXTRACFLAGS += -I$(srctree)/tools/include |
---|
64 | 77 | |
---|
65 | 78 | sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABCDGRSTVW] \(_text\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p' |
---|
.. | .. |
---|
74 | 87 | |
---|
75 | 88 | $(obj)/misc.o: $(obj)/../voffset.h |
---|
76 | 89 | |
---|
77 | | -vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ |
---|
78 | | - $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \ |
---|
| 90 | +vmlinux-objs-y := $(obj)/vmlinux.lds $(obj)/kernel_info.o $(obj)/head_$(BITS).o \ |
---|
| 91 | + $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/error.o \ |
---|
79 | 92 | $(obj)/piggy.o $(obj)/cpuflags.o |
---|
80 | 93 | |
---|
81 | 94 | vmlinux-objs-$(CONFIG_EARLY_PRINTK) += $(obj)/early_serial_console.o |
---|
82 | 95 | vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/kaslr.o |
---|
83 | 96 | ifdef CONFIG_X86_64 |
---|
84 | | - vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/kaslr_64.o |
---|
| 97 | + vmlinux-objs-y += $(obj)/ident_map_64.o |
---|
| 98 | + vmlinux-objs-y += $(obj)/idt_64.o $(obj)/idt_handlers_64.o |
---|
85 | 99 | vmlinux-objs-y += $(obj)/mem_encrypt.o |
---|
86 | 100 | vmlinux-objs-y += $(obj)/pgtable_64.o |
---|
| 101 | + vmlinux-objs-$(CONFIG_AMD_MEM_ENCRYPT) += $(obj)/sev-es.o |
---|
87 | 102 | endif |
---|
88 | 103 | |
---|
89 | | -$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone |
---|
| 104 | +vmlinux-objs-$(CONFIG_ACPI) += $(obj)/acpi.o |
---|
90 | 105 | |
---|
91 | | -vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ |
---|
92 | | - $(objtree)/drivers/firmware/efi/libstub/lib.a |
---|
93 | 106 | vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o |
---|
| 107 | +efi-obj-$(CONFIG_EFI_STUB) = $(objtree)/drivers/firmware/efi/libstub/lib.a |
---|
94 | 108 | |
---|
95 | | -# The compressed kernel is built with -fPIC/-fPIE so that a boot loader |
---|
96 | | -# can place it anywhere in memory and it will still run. However, since |
---|
97 | | -# it is executed as-is without any ELF relocation processing performed |
---|
98 | | -# (and has already had all relocation sections stripped from the binary), |
---|
99 | | -# none of the code can use data relocations (e.g. static assignments of |
---|
100 | | -# pointer values), since they will be meaningless at runtime. This check |
---|
101 | | -# will refuse to link the vmlinux if any of these relocations are found. |
---|
102 | | -quiet_cmd_check_data_rel = DATAREL $@ |
---|
103 | | -define cmd_check_data_rel |
---|
104 | | - for obj in $(filter %.o,$^); do \ |
---|
105 | | - $(READELF) -S $$obj | grep -qF .rel.local && { \ |
---|
106 | | - echo "error: $$obj has data relocations!" >&2; \ |
---|
107 | | - exit 1; \ |
---|
108 | | - } || true; \ |
---|
109 | | - done |
---|
110 | | -endef |
---|
111 | | - |
---|
112 | | -# We need to run two commands under "if_changed", so merge them into a |
---|
113 | | -# single invocation. |
---|
114 | | -quiet_cmd_check-and-link-vmlinux = LD $@ |
---|
115 | | - cmd_check-and-link-vmlinux = $(cmd_check_data_rel); $(cmd_ld) |
---|
116 | | - |
---|
117 | | -$(obj)/vmlinux: $(vmlinux-objs-y) FORCE |
---|
118 | | - $(call if_changed,check-and-link-vmlinux) |
---|
| 109 | +$(obj)/vmlinux: $(vmlinux-objs-y) $(efi-obj-y) FORCE |
---|
| 110 | + $(call if_changed,ld) |
---|
119 | 111 | |
---|
120 | 112 | OBJCOPYFLAGS_vmlinux.bin := -R .comment -S |
---|
121 | 113 | $(obj)/vmlinux.bin: vmlinux FORCE |
---|
.. | .. |
---|
144 | 136 | $(call if_changed,lzo) |
---|
145 | 137 | $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE |
---|
146 | 138 | $(call if_changed,lz4) |
---|
| 139 | +$(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE |
---|
| 140 | + $(call if_changed,zstd22) |
---|
147 | 141 | |
---|
148 | 142 | suffix-$(CONFIG_KERNEL_GZIP) := gz |
---|
149 | 143 | suffix-$(CONFIG_KERNEL_BZIP2) := bz2 |
---|
.. | .. |
---|
151 | 145 | suffix-$(CONFIG_KERNEL_XZ) := xz |
---|
152 | 146 | suffix-$(CONFIG_KERNEL_LZO) := lzo |
---|
153 | 147 | suffix-$(CONFIG_KERNEL_LZ4) := lz4 |
---|
| 148 | +suffix-$(CONFIG_KERNEL_ZSTD) := zst |
---|
154 | 149 | |
---|
155 | 150 | quiet_cmd_mkpiggy = MKPIGGY $@ |
---|
156 | | - cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false ) |
---|
| 151 | + cmd_mkpiggy = $(obj)/mkpiggy $< > $@ |
---|
157 | 152 | |
---|
158 | 153 | targets += piggy.S |
---|
159 | 154 | $(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE |
---|