Skip to content

Commit ced23d2

Browse files
committed
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: 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>
1 parent ca65346 commit ced23d2

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

tools/objtool/Documentation/objtool.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ Objtool warnings
246246

247247
NOTE: When requesting help with an objtool warning, please recreate with
248248
OBJTOOL_VERBOSE=1 (e.g., "make OBJTOOL_VERBOSE=1") and send the full
249-
output, including any disassembly below the warning, to the objtool
250-
maintainers.
249+
output, including any disassembly or backtrace below the warning, to the
250+
objtool maintainers.
251251

252252
For asm files, if you're getting an error which doesn't make sense,
253253
first make sure that the affected code follows the above rules.

tools/objtool/check.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,8 +3657,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
36573657

36583658
ret = validate_branch(file, func, alt->insn, state);
36593659
if (ret) {
3660-
if (opts.backtrace)
3661-
BT_FUNC("(alt)", insn);
3660+
BT_INSN(insn, "(alt)");
36623661
return ret;
36633662
}
36643663
}
@@ -3703,8 +3702,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
37033702
ret = validate_branch(file, func,
37043703
insn->jump_dest, state);
37053704
if (ret) {
3706-
if (opts.backtrace)
3707-
BT_FUNC("(branch)", insn);
3705+
BT_INSN(insn, "(branch)");
37083706
return ret;
37093707
}
37103708
}
@@ -3802,8 +3800,8 @@ static int validate_unwind_hint(struct objtool_file *file,
38023800
{
38033801
if (insn->hint && !insn->visited && !insn->ignore) {
38043802
int ret = validate_branch(file, insn_func(insn), insn, *state);
3805-
if (ret && opts.backtrace)
3806-
BT_FUNC("<=== (hint)", insn);
3803+
if (ret)
3804+
BT_INSN(insn, "<=== (hint)");
38073805
return ret;
38083806
}
38093807

@@ -3861,8 +3859,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
38613859

38623860
ret = validate_unret(file, alt->insn);
38633861
if (ret) {
3864-
if (opts.backtrace)
3865-
BT_FUNC("(alt)", insn);
3862+
BT_INSN(insn, "(alt)");
38663863
return ret;
38673864
}
38683865
}
@@ -3888,10 +3885,8 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
38883885
}
38893886
ret = validate_unret(file, insn->jump_dest);
38903887
if (ret) {
3891-
if (opts.backtrace) {
3892-
BT_FUNC("(branch%s)", insn,
3893-
insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
3894-
}
3888+
BT_INSN(insn, "(branch%s)",
3889+
insn->type == INSN_JUMP_CONDITIONAL ? "-cond" : "");
38953890
return ret;
38963891
}
38973892

@@ -3913,8 +3908,7 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
39133908

39143909
ret = validate_unret(file, dest);
39153910
if (ret) {
3916-
if (opts.backtrace)
3917-
BT_FUNC("(call)", insn);
3911+
BT_INSN(insn, "(call)");
39183912
return ret;
39193913
}
39203914
/*
@@ -4216,8 +4210,8 @@ static int validate_symbol(struct objtool_file *file, struct section *sec,
42164210
state->uaccess = sym->uaccess_safe;
42174211

42184212
ret = validate_branch(file, insn_func(insn), insn, *state);
4219-
if (ret && opts.backtrace)
4220-
BT_FUNC("<=== (sym)", insn);
4213+
if (ret)
4214+
BT_INSN(insn, "<=== (sym)");
42214215
return ret;
42224216
}
42234217

tools/objtool/include/objtool/warn.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ static inline char *offstr(struct section *sec, unsigned long offset)
6363
_insn->sym->warned = 1; \
6464
})
6565

66-
#define BT_FUNC(format, insn, ...) \
67-
({ \
68-
struct instruction *_insn = (insn); \
69-
char *_str = offstr(_insn->sec, _insn->offset); \
70-
WARN(" %s: " format, _str, ##__VA_ARGS__); \
71-
free(_str); \
66+
#define BT_INSN(insn, format, ...) \
67+
({ \
68+
if (opts.verbose || opts.backtrace) { \
69+
struct instruction *_insn = (insn); \
70+
char *_str = offstr(_insn->sec, _insn->offset); \
71+
WARN(" %s: " format, _str, ##__VA_ARGS__); \
72+
free(_str); \
73+
} \
7274
})
7375

7476
#define WARN_ELF(format, ...) \

0 commit comments

Comments
 (0)