Re: [PATCH 4/8] objtool: Add support for intra-function calls
From: Miroslav Benes
Date: Fri Apr 24 2020 - 10:07:38 EST
> ---
>
> diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
> index 6340ea0dd527..be6520155cfd 100644
> --- a/tools/objtool/arch/x86/decode.c
> +++ b/tools/objtool/arch/x86/decode.c
> @@ -100,6 +100,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
> rex_x = 0, modrm = 0, modrm_mod = 0, modrm_rm = 0,
> modrm_reg = 0, sib = 0;
> struct stack_op *op = NULL;
> + struct symbol *sym;
>
> x86_64 = is_x86_64(elf);
> if (x86_64 == -1)
> @@ -496,22 +497,24 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
> *type = INSN_RETURN;
> break;
>
> - case 0xcf: /* iret */
> - *type = INSN_EXCEPTION_RETURN;
> -
> - ADD_OP(op) {
> - /* add $40, %rsp */
> - op->src.type = OP_SRC_ADD;
> - op->src.reg = CFI_SP;
> - op->src.offset = 5*8;
> - op->dest.type = OP_DEST_REG;
> - op->dest.reg = CFI_SP;
> - }
> - break;
> -
> case 0xca: /* retf */
> case 0xcb: /* retf */
> + case 0xcf: /* iret */
> *type = INSN_CONTEXT_SWITCH;
> +
> + sym = find_symbol_by_offset(sec, offset);
sym = find_symbol_containing(sec, offset);
of course
> + if (sym && sym->type == STT_FUNC) {
> + *type = INSN_OTHER;
> +
> + ADD_OP(op) {
> + /* add $40, %rsp */
> + op->src.type = OP_SRC_ADD;
> + op->src.reg = CFI_SP;
> + op->src.offset = 5*8;
> + op->dest.type = OP_DEST_REG;
> + op->dest.reg = CFI_SP;
> + }
> + }
> break;