Skip to content

Commit

Permalink
Makefile: support flag -fsanitizer-coverage=trace-cmp
Browse files Browse the repository at this point in the history
The flag enables Clang instrumentation of comparison operations
(currently not supported by GCC).  This instrumentation is needed by the
new KCOV device to collect comparison operands.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Victor Chibotaru <[email protected]>
Signed-off-by: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Andrey Konovalov <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Alexander Popov <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Vegard Nossum <[email protected]>
Cc: Quentin Casasnovas <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Victor Chibotaru authored and torvalds committed Nov 18, 2017
1 parent ded97d2 commit d677a4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ CFLAGS_KERNEL =
AFLAGS_KERNEL =
LDFLAGS_vmlinux =
CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,)
CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)


# Use USERINCLUDE when you must reference the UAPI directories only.
USERINCLUDE := \
Expand Down Expand Up @@ -659,6 +657,7 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLA
KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
endif

include scripts/Makefile.kcov
include scripts/Makefile.gcc-plugins

ifdef CONFIG_READABLE_ASM
Expand Down
10 changes: 10 additions & 0 deletions lib/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,16 @@ config KCOV

For more details, see Documentation/dev-tools/kcov.rst.

config KCOV_ENABLE_COMPARISONS
bool "Enable comparison operands collection by KCOV"
depends on KCOV
default n
help
KCOV also exposes operands of every comparison in the instrumented
code along with operand sizes and PCs of the comparison instructions.
These operands can be used by fuzzing engines to improve the quality
of fuzzing coverage.

config KCOV_INSTRUMENT_ALL
bool "Instrument all code by default"
depends on KCOV
Expand Down
7 changes: 7 additions & 0 deletions scripts/Makefile.kcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ifdef CONFIG_KCOV
CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
ifeq ($(CONFIG_KCOV_ENABLE_COMPARISONS),y)
CFLAGS_KCOV += $(call cc-option,-fsanitize-coverage=trace-cmp,)
endif

endif

0 comments on commit d677a4d

Please sign in to comment.