create-diff-object: convert rela_insn() to take normal 'sec'

rela_insn() only cares about the base section.  Convert it to take a
non-rela section as its argument instead of a relasec.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
Josh Poimboeuf 2022-05-11 14:50:43 -07:00
parent bf212f7750
commit 6b1895a6b7
1 changed files with 5 additions and 5 deletions

View File

@ -1477,13 +1477,13 @@ static void kpatch_compare_correlated_elements(struct kpatch_elf *kelf)
kpatch_compare_symbols(&kelf->symbols); kpatch_compare_symbols(&kelf->symbols);
} }
static void rela_insn(const struct section *relasec, const struct rela *rela, static void rela_insn(const struct section *sec, const struct rela *rela,
struct insn *insn) struct insn *insn)
{ {
unsigned long insn_addr, start, end, rela_addr; unsigned long insn_addr, start, end, rela_addr;
start = (unsigned long)relasec->base->data->d_buf; start = (unsigned long)sec->data->d_buf;
end = start + relasec->base->sh.sh_size; end = start + sec->sh.sh_size;
if (end <= start) if (end <= start)
ERROR("bad section size"); ERROR("bad section size");
@ -1494,7 +1494,7 @@ static void rela_insn(const struct section *relasec, const struct rela *rela,
insn_get_length(insn); insn_get_length(insn);
if (!insn->length) if (!insn->length)
ERROR("can't decode instruction in section %s at offset 0x%lx", ERROR("can't decode instruction in section %s at offset 0x%lx",
relasec->base->name, insn_addr); sec->name, insn_addr);
if (rela_addr >= insn_addr && if (rela_addr >= insn_addr &&
rela_addr < insn_addr + insn->length) rela_addr < insn_addr + insn->length)
return; return;
@ -1583,7 +1583,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
rela->type == R_X86_64_PLT32 || rela->type == R_X86_64_PLT32 ||
rela->type == R_X86_64_NONE) { rela->type == R_X86_64_NONE) {
struct insn insn; struct insn insn;
rela_insn(relasec, rela, &insn); rela_insn(relasec->base, rela, &insn);
add_off = (unsigned int)((long)insn.next_byte - add_off = (unsigned int)((long)insn.next_byte -
(long)relasec->base->data->d_buf - (long)relasec->base->data->d_buf -
rela->offset); rela->offset);