[PATCH 19/35] objtool: Skip static assert when KCOV/KASAN

From: Peter Zijlstra
Date: Thu Jan 18 2018 - 10:10:03 EST


They make an absolutely horrid mess of things.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
scripts/Makefile.build | 9 +++++++++
tools/objtool/builtin-check.c | 3 ++-
tools/objtool/builtin.h | 2 +-
tools/objtool/check.c | 3 +++
4 files changed, 15 insertions(+), 2 deletions(-)

--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -274,6 +274,15 @@ ifneq ($(RETPOLINE_CFLAGS),)
objtool_args += --retpoline
endif
endif
+ifdef CONFIG_KCOV
+ objtool_no_assert := 1
+endif
+ifdef CONFIG_KASAN
+ objtool_no_assert := 1
+endif
+ifdef objtool_no_assert
+ objtool_args += --no-static-assert
+endif


ifdef CONFIG_MODVERSIONS
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -29,7 +29,7 @@
#include "builtin.h"
#include "check.h"

-bool no_fp, no_unreachable, retpoline;
+bool no_fp, no_unreachable, retpoline, no_assert;

static const char * const check_usage[] = {
"objtool check [<options>] file.o",
@@ -40,6 +40,7 @@ const struct option check_options[] = {
OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"),
OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"),
OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"),
+ OPT_BOOLEAN('s', "no-static-assert", &no_assert, "Skip static branch validation"),
OPT_END(),
};

--- a/tools/objtool/builtin.h
+++ b/tools/objtool/builtin.h
@@ -20,7 +20,7 @@
#include <subcmd/parse-options.h>

extern const struct option check_options[];
-extern bool no_fp, no_unreachable, retpoline;
+extern bool no_fp, no_unreachable, retpoline, no_assert;

extern int cmd_check(int argc, const char **argv);
extern int cmd_orc(int argc, const char **argv);
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1122,6 +1122,9 @@ static int assert_static_jumps(struct ob
struct rela *rela;
int i;

+ if (no_assert)
+ return 0;
+
sec = find_section_by_name(file->elf, ".discard.jump_assert");
if (!sec)
return 0;