Skip to content

Commit

Permalink
objtool: Fix CONFIG_STACK_VALIDATION=y warning for out-of-tree modules
Browse files Browse the repository at this point in the history
When building a CONFIG_STACK_VALIDATION enabled kernel without the
libelf devel package installed, the Makefile prints a warning:

  "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel"

But when building an out-of-tree module, the warning doesn't show.
Instead it tries to use objtool, and the build fails with:

  /bin/sh: ./tools/objtool/objtool: No such file or directory

Make sure the warning and the disabling of objtool occur in all cases,
by moving the CONFIG_STACK_VALIDATION checks outside the 'ifeq
($(KBUILD_EXTMOD),)' block in the Makefile.

Tested-By: Marc MERLIN <[email protected]>
Suggested-by: Jessica Yu <[email protected]>
Reported-by: Marc MERLIN <[email protected]>
Signed-off-by: Josh Poimboeuf <[email protected]>
Reviewed-by: Jessica Yu <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Fixes: 3b27a0c ("objtool: Detect and warn if libelf is missing and don't break the build")
Link: http://lkml.kernel.org/r/b3088ae4a8698143d4851965793c61fec2135b1f.1487182864.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
jpoimboe authored and Ingo Molnar committed Feb 20, 2017
1 parent c470abd commit 9f0c18a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,18 @@ mod_sign_cmd = true
endif
export mod_sign_cmd

ifdef CONFIG_STACK_VALIDATION
has_libelf := $(call try-run,\
echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
ifeq ($(has_libelf),1)
objtool_target := tools/objtool FORCE
else
$(warning "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel")
SKIP_STACK_VALIDATION := 1
export SKIP_STACK_VALIDATION
endif
endif


ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
Expand Down Expand Up @@ -1035,18 +1047,6 @@ prepare0: archprepare gcc-plugins
# All the preparing..
prepare: prepare0 prepare-objtool

ifdef CONFIG_STACK_VALIDATION
has_libelf := $(call try-run,\
echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
ifeq ($(has_libelf),1)
objtool_target := tools/objtool FORCE
else
$(warning "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel")
SKIP_STACK_VALIDATION := 1
export SKIP_STACK_VALIDATION
endif
endif

PHONY += prepare-objtool
prepare-objtool: $(objtool_target)

Expand Down

0 comments on commit 9f0c18a

Please sign in to comment.