mirror of
https://github.com/dynup/kpatch
synced 2025-02-18 10:46:55 +00:00
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)
|
} 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)
|
static void __kpatch_correlate_section(struct section *sec1, struct section *sec2)
|
||||||
{
|
{
|
||||||
CORRELATE_ELEMENT(sec1, sec2, "section");
|
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");
|
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)
|
static void kpatch_correlate_section(struct section *sec1, struct section *sec2)
|
||||||
{
|
{
|
||||||
__kpatch_correlate_section(sec1, 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))
|
if (!kpatch_is_normal_static_local(sym))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sym->twin) {
|
if (sym->twin)
|
||||||
sym->twin->twin = NULL;
|
UNCORRELATE_ELEMENT(sym);
|
||||||
sym->twin = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bundled = sym == sym->sec->sym;
|
bundled = sym == sym->sec->sym;
|
||||||
if (bundled && sym->sec->twin) {
|
if (bundled && sym->sec->twin) {
|
||||||
sym->sec->twin->twin = NULL;
|
UNCORRELATE_ELEMENT(sym->sec);
|
||||||
sym->sec->twin = NULL;
|
|
||||||
|
|
||||||
sym->sec->secsym->twin->twin = NULL;
|
UNCORRELATE_ELEMENT(sym->sec->secsym);
|
||||||
sym->sec->secsym->twin = NULL;
|
|
||||||
|
|
||||||
if (sym->sec->rela) {
|
if (sym->sec->rela)
|
||||||
sym->sec->rela->twin->twin = NULL;
|
UNCORRELATE_ELEMENT(sym->sec->rela);
|
||||||
sym->sec->rela->twin = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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",
|
ERROR("sections %s and %s aren't correlated for symbol %s",
|
||||||
sym->sec->name, patched_sym->sec->name, sym->name);
|
sym->sec->name, patched_sym->sec->name, sym->name);
|
||||||
|
|
||||||
log_debug("renaming and correlating static local %s to %s\n",
|
kpatch_correlate_static_local(sym, patched_sym);
|
||||||
patched_sym->name, sym->name);
|
|
||||||
|
|
||||||
patched_sym->name = strdup(sym->name);
|
if (bundled)
|
||||||
sym->twin = patched_sym;
|
kpatch_correlate_section(sym->sec, patched_sym->sec);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user