]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
objtool: Include backtrace in verbose mode
authorJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 18 Apr 2023 21:27:49 +0000 (14:27 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 16 May 2023 13:31:52 +0000 (06:31 -0700)
Include backtrace in verbose mode.  This makes it easy to gather all the
information needed for diagnosing objtool warnings.

Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/c255224fabcf7e64bac232fec1c77c9fc2d7d7ab.1681853186.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/Documentation/objtool.txt
tools/objtool/check.c
tools/objtool/include/objtool/warn.h

index 8db1f29bf4326f16d4c04ec650a4007cfe129039..9ec8cbf20668b146ace6cac69a6827474df3bffd 100644 (file)
@@ -246,8 +246,8 @@ Objtool warnings
 
 NOTE: When requesting help with an objtool warning, please recreate with
 OBJTOOL_VERBOSE=1 (e.g., "make OBJTOOL_VERBOSE=1") and send the full
-output, including any disassembly below the warning, to the objtool
-maintainers.
+output, including any disassembly or backtrace below the warning, to the
+objtool maintainers.
 
 For asm files, if you're getting an error which doesn't make sense,
 first make sure that the affected code follows the above rules.
index 0bd0ca4c767ccb0c0a00e4d46f673f31b01d6c79..71985f3a6fa64659126327b271eedbbdd6c8ce64 100644 (file)
@@ -3657,8 +3657,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
 
                                ret = validate_branch(file, func, alt->insn, state);
                                if (ret) {
-                                       if (opts.backtrace)
-                                               BT_FUNC("(alt)", insn);
+                                       BT_INSN(insn, "(alt)");
                                        return ret;
                                }
                        }
@@ -3703,8 +3702,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
                                ret = validate_branch(file, func,
                                                      insn->jump_dest, state);
                                if (ret) {
-                                       if (opts.backtrace)
-                                               BT_FUNC("(branch)", insn);
+                                       BT_INSN(insn, "(branch)");
                                        return ret;
                                }
                        }
@@ -3802,8 +3800,8 @@ static int validate_unwind_hint(struct objtool_file *file,
 {
        if (insn->hint && !insn->visited && !insn->ignore) {
                int ret = validate_branch(file, insn_func(insn), insn, *state);
-               if (ret && opts.backtrace)
-                       BT_FUNC("<=== (hint)", insn);
+               if (ret)
+                       BT_INSN(insn, "<=== (hint)");
                return ret;
        }
 
@@ -3861,8 +3859,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
 
                                ret = validate_unret(file, alt->insn);
                                if (ret) {
-                                       if (opts.backtrace)
-                                               BT_FUNC("(alt)", insn);
+                                       BT_INSN(insn, "(alt)");
                                        return ret;
                                }
                        }
@@ -3888,10 +3885,8 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
                                }
                                ret = validate_unret(file, insn->jump_dest);
                                if (ret) {
-                                       if (opts.backtrace) {
-                                               BT_FUNC("(branch%s)", insn,
-                                                       insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
-                                       }
+                                       BT_INSN(insn, "(branch%s)",
+                                               insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
                                        return ret;
                                }
 
@@ -3913,8 +3908,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
 
                        ret = validate_unret(file, dest);
                        if (ret) {
-                               if (opts.backtrace)
-                                       BT_FUNC("(call)", insn);
+                               BT_INSN(insn, "(call)");
                                return ret;
                        }
                        /*
@@ -4216,8 +4210,8 @@ static int validate_symbol(struct objtool_file *file, struct section *sec,
        state->uaccess = sym->uaccess_safe;
 
        ret = validate_branch(file, insn_func(insn), insn, *state);
-       if (ret && opts.backtrace)
-               BT_FUNC("<=== (sym)", insn);
+       if (ret)
+               BT_INSN(insn, "<=== (sym)");
        return ret;
 }
 
index f195deab456e44edf95334a3c84d22f9bb863f5a..ac04d3fe4dd9c17e1197f5b07b4fa71e8a72e3bb 100644 (file)
@@ -63,12 +63,14 @@ static inline char *offstr(struct section *sec, unsigned long offset)
                _insn->sym->warned = 1;                                 \
 })
 
-#define BT_FUNC(format, insn, ...)                     \
-({                                                     \
-       struct instruction *_insn = (insn);             \
-       char *_str = offstr(_insn->sec, _insn->offset); \
-       WARN("  %s: " format, _str, ##__VA_ARGS__);     \
-       free(_str);                                     \
+#define BT_INSN(insn, format, ...)                             \
+({                                                             \
+       if (opts.verbose || opts.backtrace) {                   \
+               struct instruction *_insn = (insn);             \
+               char *_str = offstr(_insn->sec, _insn->offset); \
+               WARN("  %s: " format, _str, ##__VA_ARGS__);     \
+               free(_str);                                     \
+       }                                                       \
 })
 
 #define WARN_ELF(format, ...)                          \