Commit 246b2c85 authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Peter Zijlstra

objtool: Add WARN_INSN()

It's easier to use and also gives easy access to the instruction's
containing function, which is useful for printing that function's
symbol.  It will also be useful in the future for rate-limiting and
disassembly of warned functions.
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/2eaa3155c90fba683d8723599f279c46025b75f3.1681325924.git.jpoimboe@kernel.org
parent 27d000d6
This diff is collapsed.
...@@ -53,6 +53,11 @@ static inline char *offstr(struct section *sec, unsigned long offset) ...@@ -53,6 +53,11 @@ static inline char *offstr(struct section *sec, unsigned long offset)
free(_str); \ free(_str); \
}) })
#define WARN_INSN(insn, format, ...) \
({ \
WARN_FUNC(format, insn->sec, insn->offset, ##__VA_ARGS__); \
})
#define BT_FUNC(format, insn, ...) \ #define BT_FUNC(format, insn, ...) \
({ \ ({ \
struct instruction *_insn = (insn); \ struct instruction *_insn = (insn); \
......
...@@ -47,8 +47,7 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, ...@@ -47,8 +47,7 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
orc->type = ORC_TYPE_REGS_PARTIAL; orc->type = ORC_TYPE_REGS_PARTIAL;
break; break;
default: default:
WARN_FUNC("unknown unwind hint type %d", WARN_INSN(insn, "unknown unwind hint type %d", cfi->type);
insn->sec, insn->offset, cfi->type);
return -1; return -1;
} }
...@@ -80,8 +79,7 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, ...@@ -80,8 +79,7 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
orc->sp_reg = ORC_REG_DX; orc->sp_reg = ORC_REG_DX;
break; break;
default: default:
WARN_FUNC("unknown CFA base reg %d", WARN_INSN(insn, "unknown CFA base reg %d", cfi->cfa.base);
insn->sec, insn->offset, cfi->cfa.base);
return -1; return -1;
} }
...@@ -96,8 +94,7 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi, ...@@ -96,8 +94,7 @@ static int init_orc_entry(struct orc_entry *orc, struct cfi_state *cfi,
orc->bp_reg = ORC_REG_BP; orc->bp_reg = ORC_REG_BP;
break; break;
default: default:
WARN_FUNC("unknown BP base reg %d", WARN_INSN(insn, "unknown BP base reg %d", bp->base);
insn->sec, insn->offset, bp->base);
return -1; return -1;
} }
......
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