Commit ced23d2e authored by Josh Poimboeuf's avatar Josh Poimboeuf

objtool: Include backtrace in verbose mode

Include backtrace in verbose mode.  This makes it easy to gather all the
information needed for diagnosing objtool warnings.
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/c255224fabcf7e64bac232fec1c77c9fc2d7d7ab.1681853186.git.jpoimboe@kernel.orgSigned-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
parent ca653464
...@@ -246,8 +246,8 @@ Objtool warnings ...@@ -246,8 +246,8 @@ Objtool warnings
NOTE: When requesting help with an objtool warning, please recreate with NOTE: When requesting help with an objtool warning, please recreate with
OBJTOOL_VERBOSE=1 (e.g., "make OBJTOOL_VERBOSE=1") and send the full OBJTOOL_VERBOSE=1 (e.g., "make OBJTOOL_VERBOSE=1") and send the full
output, including any disassembly below the warning, to the objtool output, including any disassembly or backtrace below the warning, to the
maintainers. objtool maintainers.
For asm files, if you're getting an error which doesn't make sense, 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. first make sure that the affected code follows the above rules.
......
...@@ -3657,8 +3657,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, ...@@ -3657,8 +3657,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
ret = validate_branch(file, func, alt->insn, state); ret = validate_branch(file, func, alt->insn, state);
if (ret) { if (ret) {
if (opts.backtrace) BT_INSN(insn, "(alt)");
BT_FUNC("(alt)", insn);
return ret; return ret;
} }
} }
...@@ -3703,8 +3702,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, ...@@ -3703,8 +3702,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
ret = validate_branch(file, func, ret = validate_branch(file, func,
insn->jump_dest, state); insn->jump_dest, state);
if (ret) { if (ret) {
if (opts.backtrace) BT_INSN(insn, "(branch)");
BT_FUNC("(branch)", insn);
return ret; return ret;
} }
} }
...@@ -3802,8 +3800,8 @@ static int validate_unwind_hint(struct objtool_file *file, ...@@ -3802,8 +3800,8 @@ static int validate_unwind_hint(struct objtool_file *file,
{ {
if (insn->hint && !insn->visited && !insn->ignore) { if (insn->hint && !insn->visited && !insn->ignore) {
int ret = validate_branch(file, insn_func(insn), insn, *state); int ret = validate_branch(file, insn_func(insn), insn, *state);
if (ret && opts.backtrace) if (ret)
BT_FUNC("<=== (hint)", insn); BT_INSN(insn, "<=== (hint)");
return ret; return ret;
} }
...@@ -3861,8 +3859,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn) ...@@ -3861,8 +3859,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
ret = validate_unret(file, alt->insn); ret = validate_unret(file, alt->insn);
if (ret) { if (ret) {
if (opts.backtrace) BT_INSN(insn, "(alt)");
BT_FUNC("(alt)", insn);
return ret; return ret;
} }
} }
...@@ -3888,10 +3885,8 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn) ...@@ -3888,10 +3885,8 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
} }
ret = validate_unret(file, insn->jump_dest); ret = validate_unret(file, insn->jump_dest);
if (ret) { if (ret) {
if (opts.backtrace) { BT_INSN(insn, "(branch%s)",
BT_FUNC("(branch%s)", insn, insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
}
return ret; return ret;
} }
...@@ -3913,8 +3908,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn) ...@@ -3913,8 +3908,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
ret = validate_unret(file, dest); ret = validate_unret(file, dest);
if (ret) { if (ret) {
if (opts.backtrace) BT_INSN(insn, "(call)");
BT_FUNC("(call)", insn);
return ret; return ret;
} }
/* /*
...@@ -4216,8 +4210,8 @@ static int validate_symbol(struct objtool_file *file, struct section *sec, ...@@ -4216,8 +4210,8 @@ static int validate_symbol(struct objtool_file *file, struct section *sec,
state->uaccess = sym->uaccess_safe; state->uaccess = sym->uaccess_safe;
ret = validate_branch(file, insn_func(insn), insn, *state); ret = validate_branch(file, insn_func(insn), insn, *state);
if (ret && opts.backtrace) if (ret)
BT_FUNC("<=== (sym)", insn); BT_INSN(insn, "<=== (sym)");
return ret; return ret;
} }
......
...@@ -63,12 +63,14 @@ static inline char *offstr(struct section *sec, unsigned long offset) ...@@ -63,12 +63,14 @@ static inline char *offstr(struct section *sec, unsigned long offset)
_insn->sym->warned = 1; \ _insn->sym->warned = 1; \
}) })
#define BT_FUNC(format, insn, ...) \ #define BT_INSN(insn, format, ...) \
({ \ ({ \
struct instruction *_insn = (insn); \ if (opts.verbose || opts.backtrace) { \
char *_str = offstr(_insn->sec, _insn->offset); \ struct instruction *_insn = (insn); \
WARN(" %s: " format, _str, ##__VA_ARGS__); \ char *_str = offstr(_insn->sec, _insn->offset); \
free(_str); \ WARN(" %s: " format, _str, ##__VA_ARGS__); \
free(_str); \
} \
}) })
#define WARN_ELF(format, ...) \ #define WARN_ELF(format, ...) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment