Skip to content

Commit c7e41b0

Browse files
committed
tools/objtool: Convert to insn_decode()
Simplify code, no functional changes. Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20210304174237.31945-18-bp@alien8.de
1 parent 0c925c6 commit c7e41b0

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎tools/objtool/arch/x86/decode.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
9090
struct list_head *ops_list)
9191
{
9292
struct insn insn;
93-
int x86_64, sign;
93+
int x86_64, sign, ret;
9494
unsigned char op1, op2, rex = 0, rex_b = 0, rex_r = 0, rex_w = 0,
9595
rex_x = 0, modrm = 0, modrm_mod = 0, modrm_rm = 0,
9696
modrm_reg = 0, sib = 0;
@@ -101,10 +101,9 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
101101
if (x86_64 == -1)
102102
return -1;
103103

104-
insn_init(&insn, sec->data->d_buf + offset, maxlen, x86_64);
105-
insn_get_length(&insn);
106-
107-
if (!insn_complete(&insn)) {
104+
ret = insn_decode(&insn, sec->data->d_buf + offset, maxlen,
105+
x86_64 ? INSN_MODE_64 : INSN_MODE_32);
106+
if (ret < 0) {
108107
WARN("can't decode instruction at %s:0x%lx", sec->name, offset);
109108
return -1;
110109
}

0 commit comments

Comments
 (0)