From ebf55f86149db89028dc2e13cae5cc7258ba30a5 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 28 Jul 2014 11:08:52 -0500 Subject: [PATCH] add support for replacing section syms for unbundled sections Right now, the test patch unnecessarily includes hrtimer_nanosleep() because the call to do_nanosleep() generates a rela the references the unbundled .sched.text section. This section symbol is not currently replaced by kpatch_replace_sections_syms() as it only replaces bundled sections symbols. This commit adds logic to kpatch_replace_sections_syms() to replace unbundled section symbols as well by scanning the symbol table for symbols that start at the rela entry's offset within the matching section. This allows for properly rela section correlation when the functions have moved from an unbundled section to a bundled section. Signed-off-by: Seth Jennings --- kpatch-build/create-diff-object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 77c81dc..3d3a4fe 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -939,7 +939,9 @@ void kpatch_replace_sections_syms(struct kpatch_elf *kelf) */ if (strcmp(rela->sym->name, ".data..percpu") && strcmp(rela->sym->name, ".data..read_mostly") && - strcmp(rela->sym->name, ".data.unlikely")) + strcmp(rela->sym->name, ".data.unlikely") && + !(rela->sym->type == STT_SECTION && rela->sym->sec && + (rela->sym->sec->sh.sh_flags & SHF_EXECINSTR))) continue; list_for_each_entry(sym, &kelf->symbols, list) {