@@ -86,18 +86,12 @@ ifdef need-builtin
86
86
targets-for-builtin += $(obj)/built-in.a
87
87
endif
88
88
89
- targets-for-modules :=
89
+ targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m)))
90
90
91
- ifdef CONFIG_LTO_CLANG
92
- targets-for-modules += $(patsubst %.o, %.lto.o, $(filter %.o, $(obj-m)))
93
- endif
94
-
95
- ifdef CONFIG_X86_KERNEL_IBT
96
- targets-for-modules += $(patsubst %.o, %.objtool, $(filter %.o, $(obj-m)))
91
+ ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
92
+ targets-for-modules += $(patsubst %.o, %.prelink.o, $(filter %.o, $(obj-m)))
97
93
endif
98
94
99
- targets-for-modules += $(patsubst %.o, %.mod, $(filter %.o, $(obj-m)))
100
-
101
95
ifdef need-modorder
102
96
targets-for-modules += $(obj)/modules.order
103
97
endif
@@ -244,31 +238,16 @@ objtool_args = \
244
238
$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
245
239
$(if $(CONFIG_SLS), --sls)
246
240
247
- cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $(@:.objtool=.o) )
248
- cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$(@:.objtool=.o) : $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
241
+ cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@ )
242
+ cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@ : $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
249
243
250
244
endif # CONFIG_STACK_VALIDATION
251
245
252
- ifdef CONFIG_LTO_CLANG
246
+ ifneq ($( CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
253
247
254
248
# Skip objtool for LLVM bitcode
255
249
$(obj)/%.o: objtool-enabled :=
256
250
257
- # objtool was skipped for LLVM bitcode, run it now that we have compiled
258
- # modules into native code
259
- $(obj)/%.lto.o: objtool-enabled = y
260
- $(obj)/%.lto.o: part-of-module := y
261
-
262
- else ifdef CONFIG_X86_KERNEL_IBT
263
-
264
- # Skip objtool on individual files
265
- $(obj)/%.o: objtool-enabled :=
266
-
267
- # instead run objtool on the module as a whole, right before
268
- # the final link pass with the linker script.
269
- $(obj)/%.objtool: objtool-enabled = y
270
- $(obj)/%.objtool: part-of-module := y
271
-
272
251
else
273
252
274
253
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
@@ -310,19 +289,24 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
310
289
$(call if_changed_rule,cc_o_c)
311
290
$(call cmd,force_checksrc)
312
291
313
- ifdef CONFIG_LTO_CLANG
292
+ ifneq ($( CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
314
293
# Module .o files may contain LLVM bitcode, compile them into native code
315
294
# before ELF processing
316
- quiet_cmd_cc_lto_link_modules = LTO [M] $@
317
- cmd_cc_lto_link_modules = \
295
+ quiet_cmd_cc_prelink_modules = LD [M] $@
296
+ cmd_cc_prelink_modules = \
318
297
$(LD) $(ld_flags) -r -o $@ \
319
- $(shell [ -s $(@:.lto .o=.o.symversions) ] && \
320
- echo -T $(@:.lto .o=.o.symversions)) \
298
+ $(shell [ -s $(@:.prelink .o=.o.symversions) ] && \
299
+ echo -T $(@:.prelink .o=.o.symversions)) \
321
300
--whole-archive $(filter-out FORCE,$^) \
322
301
$(cmd_objtool)
323
302
324
- $(obj)/%.lto.o: $(obj)/%.o FORCE
325
- $(call if_changed,cc_lto_link_modules)
303
+ # objtool was skipped for LLVM bitcode, run it now that we have compiled
304
+ # modules into native code
305
+ $(obj)/%.prelink.o: objtool-enabled = y
306
+ $(obj)/%.prelink.o: part-of-module := y
307
+
308
+ $(obj)/%.prelink.o: $(obj)/%.o FORCE
309
+ $(call if_changed,cc_prelink_modules)
326
310
endif
327
311
328
312
cmd_mod = { \
@@ -333,18 +317,6 @@ cmd_mod = { \
333
317
$(obj)/%.mod: $(obj)/%$(mod-prelink-ext).o FORCE
334
318
$(call if_changed,mod)
335
319
336
- #
337
- # Since objtool will re-write the file it will change the timestamps, therefore
338
- # it is critical that the %.objtool file gets a timestamp *after* objtool runs.
339
- #
340
- # Additionally, care must be had with ordering this rule against the other rules
341
- # that take %.o as a dependency.
342
- #
343
- cmd_objtool_mod = true $(cmd_objtool) ; touch $@
344
-
345
- $(obj)/%.objtool: $(obj)/%$(mod-prelink-ext).o FORCE
346
- $(call if_changed,objtool_mod)
347
-
348
320
quiet_cmd_cc_lst_c = MKLST $@
349
321
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
350
322
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
@@ -498,7 +470,7 @@ $(obj)/lib.a: $(lib-y) FORCE
498
470
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
499
471
# module is turned into a multi object module, $^ will contain header file
500
472
# dependencies recorded in the .*.cmd file.
501
- ifdef CONFIG_LTO_CLANG
473
+ ifneq ($( CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
502
474
quiet_cmd_link_multi-m = AR [M] $@
503
475
cmd_link_multi-m = \
504
476
$(cmd_update_lto_symversions); \
0 commit comments