mirror of
https://github.com/dynup/kpatch
synced 2025-04-18 04:55:21 +00:00
support renaming of unbundled static locals
WARN_ON_ONCE places the __warned static local variable in the .data.unlikely section, so it's not bundled (i.e. ignored by the -fdata-sections gcc flag). There's no reason why we can't rename unbundled symbols, so add support for them. Fixes #394.
This commit is contained in:
parent
017c5e6395
commit
8ac338aac4
@ -867,7 +867,7 @@ void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
|
|||||||
struct symbol *sym, *basesym;
|
struct symbol *sym, *basesym;
|
||||||
struct section *tmpsec, *sec;
|
struct section *tmpsec, *sec;
|
||||||
struct rela *rela;
|
struct rela *rela;
|
||||||
int prefixlen;
|
int prefixlen, bundled1, bundled2;
|
||||||
char *dot;
|
char *dot;
|
||||||
|
|
||||||
list_for_each_entry(sym, &patched->symbols, list) {
|
list_for_each_entry(sym, &patched->symbols, list) {
|
||||||
@ -951,19 +951,25 @@ void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
|
|||||||
if (!basesym)
|
if (!basesym)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sym != sym->sec->sym)
|
bundled1 = sym == sym->sec->sym;
|
||||||
ERROR("expected bundled section for %s", sym->name);
|
bundled2 = basesym == basesym->sec->sym;
|
||||||
if (basesym != basesym->sec->sym)
|
if (bundled1 != bundled2)
|
||||||
ERROR("expected bundled section for %s",basesym->name);
|
ERROR("bundle mismatch for symbol %s", sym->name);
|
||||||
|
if (!bundled1 && sym->sec->twin != basesym->sec)
|
||||||
|
ERROR("sections %s and %s aren't correlated",
|
||||||
|
sym->sec->name, basesym->sec->name);
|
||||||
|
|
||||||
log_debug("renaming and correlating %s to %s\n",
|
log_debug("renaming and correlating %s to %s\n",
|
||||||
sym->name, basesym->name);
|
sym->name, basesym->name);
|
||||||
sym->name = strdup(basesym->name);
|
sym->name = strdup(basesym->name);
|
||||||
sym->twin = basesym;
|
sym->twin = basesym;
|
||||||
basesym->twin = sym;
|
basesym->twin = sym;
|
||||||
sym->sec->twin = basesym->sec;
|
|
||||||
basesym->sec->twin = sym->sec;
|
|
||||||
sym->status = basesym->status = SAME;
|
sym->status = basesym->status = SAME;
|
||||||
|
|
||||||
|
if (bundled1) {
|
||||||
|
sym->sec->twin = basesym->sec;
|
||||||
|
basesym->sec->twin = sym->sec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user