From 566ee5ffa45f190e3583fe60e8e7e5ec8ea835a8 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 4 Jun 2014 09:24:19 -0500 Subject: [PATCH 1/3] create-diff-object: .isra fix When renaming a foo.isra.1 function, there might also be a foo_bar function which would be falsely matched with the current strchr logic. Instead of matching the "foo" prefix, match "foo.isra". --- kpatch-build/create-diff-object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 974436a..86519ec 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -719,8 +719,10 @@ void kpatch_rename_mangled_functions(struct kpatch_elf *base, if (sym != sym->sec->sym) ERROR("expected bundled section for %s\n", sym->name); + /* prefix of foo.isra.1.constprop.2 is foo.isra */ prefix = strdup(sym->name); dot = strchr(prefix, '.'); + dot = strchr(dot+1, '.'); *dot = '\0'; basesym = find_symbol_by_name_prefix(&base->symbols, prefix); From a91c7eb250351701ced34ae7a5ea3e6a9a56886a Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 4 Jun 2014 09:38:13 -0500 Subject: [PATCH 2/3] create-diff-object: add support for gcc-mangled .part --- kpatch-build/create-diff-object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 86519ec..688673b 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -713,7 +713,8 @@ void kpatch_rename_mangled_functions(struct kpatch_elf *base, continue; if (!strstr(sym->name, ".isra.") && - !strstr(sym->name, ".constprop.")) + !strstr(sym->name, ".constprop.") && + !strstr(sym->name, ".part.")) continue; if (sym != sym->sec->sym) From 3ffe135512fc123ac442a49b7e0367e67a6f0cb9 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 4 Jun 2014 10:38:06 -0500 Subject: [PATCH 3/3] create-diff-object: bundling for .text.unlikely symbols With -ffunction-sections, some section names are given a prefix of ".text.unlikely." rather than just ".text.". --- kpatch-build/create-diff-object.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 688673b..f54ac24 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -375,6 +375,11 @@ int is_bundleable(struct symbol *sym) !strcmp(sym->sec->name + 6, sym->name)) return 1; + if (sym->type == STT_FUNC && + !strncmp(sym->sec->name, ".text.unlikely.",15) && + !strcmp(sym->sec->name + 15, sym->name)) + return 1; + if (sym->type == STT_OBJECT && !strncmp(sym->sec->name, ".data.",6) && !strcmp(sym->sec->name + 6, sym->name))