diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 0efe881..8a47893 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -975,18 +975,26 @@ static struct symbol *kpatch_find_static_twin(struct section *sec, /* find the patched object's corresponding variable */ list_for_each_entry(rela, &sec->twin->relas, list) { + struct symbol *patched_sym; rela_toc = toc_rela(rela); if (!rela_toc) continue; /* skip toc constants */ - if (rela_toc->sym->twin) + patched_sym = rela_toc->sym; + + if (patched_sym->twin) continue; - if (kpatch_mangled_strcmp(rela_toc->sym->name, sym->name)) + if (sym->type != patched_sym->type || + (sym->type == STT_OBJECT && + sym->sym.st_size != patched_sym->sym.st_size)) continue; - return rela_toc->sym; + if (kpatch_mangled_strcmp(patched_sym->name, sym->name)) + continue; + + return patched_sym; } return NULL; diff --git a/test/unit/objs b/test/unit/objs index b068a43..6bd3e93 160000 --- a/test/unit/objs +++ b/test/unit/objs @@ -1 +1 @@ -Subproject commit b068a43723a3efcf20b096a37b4bb8543247c62a +Subproject commit 6bd3e931ef29967a0b5bb7f7b4e4dc999e38baea