[RFC v5 15/57] objtool: Support addition to set frame pointer

From: Julien Thierry
Date: Thu Jan 09 2020 - 11:05:10 EST


Support updating the frame pointer by adding an immediate value to the
stack pointer in the CFA tracking code.

Signed-off-by: Julien Thierry <jthierry@xxxxxxxxxx>
---
tools/objtool/check.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 19e96c4ad0a3..5b2539eaccba 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1394,6 +1394,18 @@ static int update_insn_state(struct instruction *insn, struct insn_state *state)
break;
}

+ if (op->src.reg == CFI_SP && cfa->base == CFI_SP &&
+ op->dest.reg == CFI_BP &&
+ regs[CFI_BP].base == CFI_CFA &&
+ regs[CFI_BP].offset == -cfa->offset + op->src.offset) {
+
+ /* lea disp(%rsp), %rbp */
+ cfa->base = CFI_BP;
+ cfa->offset -= op->src.offset;
+ state->bp_scratch = false;
+ break;
+ }
+
if (op->src.reg == CFI_SP && cfa->base == CFI_SP) {

/* drap: lea disp(%rsp), %drap */
--
2.21.0