[tip: objtool/core] objtool: is_fentry_call() crashes if call has no destination

From: tip-bot2 for Alexandre Chartre
Date: Fri May 01 2020 - 14:23:11 EST


The following commit has been merged into the objtool/core branch of tip:

Commit-ID: 87cf61fe848ca8ddf091548671e168f52e8a718e
Gitweb: https://git.kernel.org/tip/87cf61fe848ca8ddf091548671e168f52e8a718e
Author: Alexandre Chartre <alexandre.chartre@xxxxxxxxxx>
AuthorDate: Tue, 14 Apr 2020 12:36:10 +02:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Thu, 30 Apr 2020 20:14:32 +02:00

objtool: is_fentry_call() crashes if call has no destination

Fix is_fentry_call() so that it works if a call has no destination
set (call_dest). This needs to be done in order to support intra-
function calls.

Signed-off-by: Alexandre Chartre <alexandre.chartre@xxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Reviewed-by: Miroslav Benes <mbenes@xxxxxxx>
Acked-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Link: https://lkml.kernel.org/r/20200414103618.12657-2-alexandre.chartre@xxxxxxxxxx
---
tools/objtool/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index fa9bf36..8af8de2 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1484,7 +1484,7 @@ static int decode_sections(struct objtool_file *file)

static bool is_fentry_call(struct instruction *insn)
{
- if (insn->type == INSN_CALL &&
+ if (insn->type == INSN_CALL && insn->call_dest &&
insn->call_dest->type == STT_NOTYPE &&
!strcmp(insn->call_dest->name, "__fentry__"))
return true;