Commit c7e41b09 authored by Borislav Petkov's avatar Borislav Petkov

tools/objtool: Convert to insn_decode()

Simplify code, no functional changes.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210304174237.31945-18-bp@alien8.de
parent 0c925c61
...@@ -90,7 +90,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec, ...@@ -90,7 +90,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
struct list_head *ops_list) struct list_head *ops_list)
{ {
struct insn insn; struct insn insn;
int x86_64, sign; int x86_64, sign, ret;
unsigned char op1, op2, rex = 0, rex_b = 0, rex_r = 0, rex_w = 0, unsigned char op1, op2, rex = 0, rex_b = 0, rex_r = 0, rex_w = 0,
rex_x = 0, modrm = 0, modrm_mod = 0, modrm_rm = 0, rex_x = 0, modrm = 0, modrm_mod = 0, modrm_rm = 0,
modrm_reg = 0, sib = 0; modrm_reg = 0, sib = 0;
...@@ -101,10 +101,9 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec, ...@@ -101,10 +101,9 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
if (x86_64 == -1) if (x86_64 == -1)
return -1; return -1;
insn_init(&insn, sec->data->d_buf + offset, maxlen, x86_64); ret = insn_decode(&insn, sec->data->d_buf + offset, maxlen,
insn_get_length(&insn); x86_64 ? INSN_MODE_64 : INSN_MODE_32);
if (ret < 0) {
if (!insn_complete(&insn)) {
WARN("can't decode instruction at %s:0x%lx", sec->name, offset); WARN("can't decode instruction at %s:0x%lx", sec->name, offset);
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