Skip to content

Commit 9ec6ab6

Browse files
committed
kbuild: use objtool-args-y to clean up objtool arguments
Based on Linus' patch. Refactor scripts/Makefile.vmlinux_o as well. Link: https://lore.kernel.org/lkml/CAHk-=wgjTMQgiKzBZTmb=uWGDEQxDdyF1+qxBkODYciuNsmwnw@mail.gmail.com/ Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]>
1 parent cc306ab commit 9ec6ab6

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

scripts/Makefile.lib

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -229,25 +229,26 @@ ifdef CONFIG_OBJTOOL
229229

230230
objtool := $(objtree)/tools/objtool/objtool
231231

232-
objtool_args = \
233-
$(if $(CONFIG_HAVE_JUMP_LABEL_HACK), --hacks=jump_label) \
234-
$(if $(CONFIG_HAVE_NOINSTR_HACK), --hacks=noinstr) \
235-
$(if $(CONFIG_X86_KERNEL_IBT), --ibt) \
236-
$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount) \
237-
$(if $(CONFIG_UNWINDER_ORC), --orc) \
238-
$(if $(CONFIG_RETPOLINE), --retpoline) \
239-
$(if $(CONFIG_RETHUNK), --rethunk) \
240-
$(if $(CONFIG_SLS), --sls) \
241-
$(if $(CONFIG_STACK_VALIDATION), --stackval) \
242-
$(if $(CONFIG_HAVE_STATIC_CALL_INLINE), --static-call) \
243-
$(if $(CONFIG_HAVE_UACCESS_VALIDATION), --uaccess) \
232+
objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) += --hacks=jump_label
233+
objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) += --hacks=noinstr
234+
objtool-args-$(CONFIG_X86_KERNEL_IBT) += --ibt
235+
objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) += --mcount
236+
objtool-args-$(CONFIG_UNWINDER_ORC) += --orc
237+
objtool-args-$(CONFIG_RETPOLINE) += --retpoline
238+
objtool-args-$(CONFIG_RETHUNK) += --rethunk
239+
objtool-args-$(CONFIG_SLS) += --sls
240+
objtool-args-$(CONFIG_STACK_VALIDATION) += --stackval
241+
objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call
242+
objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess
243+
objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable
244+
245+
objtool-args = $(objtool-args-y) \
244246
$(if $(delay-objtool), --link) \
245-
$(if $(part-of-module), --module) \
246-
$(if $(CONFIG_GCOV_KERNEL), --no-unreachable)
247+
$(if $(part-of-module), --module)
247248

248249
delay-objtool := $(or $(CONFIG_LTO_CLANG),$(CONFIG_X86_KERNEL_IBT))
249250

250-
cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
251+
cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool-args) $@)
251252
cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
252253

253254
endif # CONFIG_OBJTOOL

scripts/Makefile.vmlinux_o

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,11 @@ endif
3535

3636
objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION))
3737

38-
# Reuse objtool_args defined in scripts/Makefile.lib if LTO or IBT is enabled.
39-
#
40-
# Add some more flags as needed.
41-
# --no-unreachable and --link might be added twice, but it is fine.
42-
#
43-
# Expand objtool_args to a simple variable to avoid circular reference.
38+
vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y)
39+
vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable
40+
vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret)
4441

45-
objtool_args := \
46-
$(if $(delay-objtool),$(objtool_args)) \
47-
$(if $(CONFIG_NOINSTR_VALIDATION), --noinstr $(if $(CONFIG_CPU_UNRET_ENTRY), --unret)) \
48-
$(if $(CONFIG_GCOV_KERNEL), --no-unreachable) \
49-
--link
42+
objtool-args = $(vmlinux-objtool-args-y) --link
5043

5144
# Link of vmlinux.o used for section mismatch analysis
5245
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)