mirror of https://github.com/dynup/kpatch
create-diff-object: Use new helpers for static local correlation
Simplify static local variable correlation and renaming code by using the newly introduced helpers for section and symbol correlation. Signed-off-by: Julien Thierry <jthierry@redhat.com>
This commit is contained in:
parent
e49e3a59c2
commit
852bad5e8d
|
@ -776,6 +776,13 @@ do { \
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define UNCORRELATE_ELEMENT(_elem_) \
|
||||
do { \
|
||||
typeof(_elem_) elem = (_elem_); \
|
||||
elem->twin->twin = NULL; \
|
||||
elem->twin = NULL; \
|
||||
} while (0)
|
||||
|
||||
static void __kpatch_correlate_section(struct section *sec1, struct section *sec2)
|
||||
{
|
||||
CORRELATE_ELEMENT(sec1, sec2, "section");
|
||||
|
@ -786,6 +793,11 @@ static void kpatch_correlate_symbol(struct symbol *sym1, struct symbol *sym2)
|
|||
CORRELATE_ELEMENT(sym1, sym2, "symbol");
|
||||
}
|
||||
|
||||
static void kpatch_correlate_static_local(struct symbol *sym1, struct symbol *sym2)
|
||||
{
|
||||
CORRELATE_ELEMENT(sym1, sym2, "static local");
|
||||
}
|
||||
|
||||
static void kpatch_correlate_section(struct section *sec1, struct section *sec2)
|
||||
{
|
||||
__kpatch_correlate_section(sec1, sec2);
|
||||
|
@ -1036,23 +1048,17 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
|
|||
if (!kpatch_is_normal_static_local(sym))
|
||||
continue;
|
||||
|
||||
if (sym->twin) {
|
||||
sym->twin->twin = NULL;
|
||||
sym->twin = NULL;
|
||||
}
|
||||
if (sym->twin)
|
||||
UNCORRELATE_ELEMENT(sym);
|
||||
|
||||
bundled = sym == sym->sec->sym;
|
||||
if (bundled && sym->sec->twin) {
|
||||
sym->sec->twin->twin = NULL;
|
||||
sym->sec->twin = NULL;
|
||||
UNCORRELATE_ELEMENT(sym->sec);
|
||||
|
||||
sym->sec->secsym->twin->twin = NULL;
|
||||
sym->sec->secsym->twin = NULL;
|
||||
UNCORRELATE_ELEMENT(sym->sec->secsym);
|
||||
|
||||
if (sym->sec->rela) {
|
||||
sym->sec->rela->twin->twin = NULL;
|
||||
sym->sec->rela->twin = NULL;
|
||||
}
|
||||
if (sym->sec->rela)
|
||||
UNCORRELATE_ELEMENT(sym->sec->rela);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1106,28 +1112,10 @@ static void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
|
|||
ERROR("sections %s and %s aren't correlated for symbol %s",
|
||||
sym->sec->name, patched_sym->sec->name, sym->name);
|
||||
|
||||
log_debug("renaming and correlating static local %s to %s\n",
|
||||
patched_sym->name, sym->name);
|
||||
kpatch_correlate_static_local(sym, patched_sym);
|
||||
|
||||
patched_sym->name = strdup(sym->name);
|
||||
sym->twin = patched_sym;
|
||||
patched_sym->twin = sym;
|
||||
|
||||
/* set initial status, might change */
|
||||
sym->status = patched_sym->status = SAME;
|
||||
|
||||
if (bundled) {
|
||||
sym->sec->twin = patched_sym->sec;
|
||||
patched_sym->sec->twin = sym->sec;
|
||||
|
||||
sym->sec->secsym->twin = patched_sym->sec->secsym;
|
||||
patched_sym->sec->secsym->twin = sym->sec->secsym;
|
||||
|
||||
if (sym->sec->rela && patched_sym->sec->rela) {
|
||||
sym->sec->rela->twin = patched_sym->sec->rela;
|
||||
patched_sym->sec->rela->twin = sym->sec->rela;
|
||||
}
|
||||
}
|
||||
if (bundled)
|
||||
kpatch_correlate_section(sym->sec, patched_sym->sec);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue