Skip to content

Commit

Permalink
kbuild: Fix objtool dependency for 'OBJECT_FILES_NON_STANDARD_<obj> :…
Browse files Browse the repository at this point in the history
…= n'

[ Upstream commit 8852c55 ]

"OBJECT_FILES_NON_STANDARD_vma.o := n" has a dependency bug.  When
objtool source is updated, the affected object doesn't get re-analyzed
by objtool.

Peter's new variable-sized jump label feature relies on objtool
rewriting the object file.  Otherwise the system can fail to boot.  That
effectively upgrades this minor dependency issue to a major bug.

The problem is that variables in prerequisites are expanded early,
during the read-in phase.  The '$(objtool_dep)' variable indirectly uses
'$@', which isn't yet available when the target prerequisites are
evaluated.

Use '.SECONDEXPANSION:' which causes '$(objtool_dep)' to be expanded in
a later phase, after the target-specific '$@' variable has been defined.

Fixes: b9ab5eb ("objtool: Add CONFIG_STACK_VALIDATION option")
Fixes: ab32570 ("jump_label, x86: Allow short NOPs")
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jpoimboe authored and gregkh committed Jul 14, 2021
1 parent 099451a commit 6b9c00b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ define rule_as_o_S
endef

# Built-in and composite module parts
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
.SECONDEXPANSION:
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $$(objtool_dep) FORCE
$(call if_changed_rule,cc_o_c)
$(call cmd,force_checksrc)

Expand Down Expand Up @@ -348,7 +349,7 @@ cmd_modversions_S = \
fi
endif

$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
$(obj)/%.o: $(src)/%.S $$(objtool_dep) FORCE
$(call if_changed_rule,as_o_S)

targets += $(filter-out $(subdir-builtin), $(real-obj-y))
Expand Down

0 comments on commit 6b9c00b

Please sign in to comment.