mirror of
https://github.com/dynup/kpatch
synced 2024-12-27 15:52:02 +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 section *tmpsec, *sec;
|
||||
struct rela *rela;
|
||||
int prefixlen;
|
||||
int prefixlen, bundled1, bundled2;
|
||||
char *dot;
|
||||
|
||||
list_for_each_entry(sym, &patched->symbols, list) {
|
||||
@ -951,19 +951,25 @@ void kpatch_correlate_static_local_variables(struct kpatch_elf *base,
|
||||
if (!basesym)
|
||||
continue;
|
||||
|
||||
if (sym != sym->sec->sym)
|
||||
ERROR("expected bundled section for %s", sym->name);
|
||||
if (basesym != basesym->sec->sym)
|
||||
ERROR("expected bundled section for %s",basesym->name);
|
||||
bundled1 = sym == sym->sec->sym;
|
||||
bundled2 = basesym == basesym->sec->sym;
|
||||
if (bundled1 != bundled2)
|
||||
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",
|
||||
sym->name, basesym->name);
|
||||
sym->name = strdup(basesym->name);
|
||||
sym->twin = basesym;
|
||||
basesym->twin = sym;
|
||||
sym->sec->twin = basesym->sec;
|
||||
basesym->sec->twin = sym->sec;
|
||||
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