From 582f2b27e0b60f0962d900546ba3cf1ca8bb7d19 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 10 Mar 2014 14:49:56 -0500 Subject: [PATCH 1/3] add comment for __ksymtab_strings case Signed-off-by: Seth Jennings --- kpatch-build/create-diff-object.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 1e06d1e68..048b673a6 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -375,6 +375,13 @@ void kpatch_create_symbol_table(struct kpatch_elf *kelf) ERROR("couldn't find section for symbol %s\n", sym->name); + /* + * __ksymtab_strings is a special case where the + * compiler creates FUNC/OBJECT syms that refer + * to offsets inside the __ksymtab_strings section + * for kernel exported symbols. We want to ignore + * those. + */ if ((sym->type == STT_FUNC || sym->type == STT_OBJECT) && sym->sym.st_value == 0 && From 8b9de305817ac8bbd336e66fa58d11249824cda7 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 10 Mar 2014 14:54:08 -0500 Subject: [PATCH 2/3] add error for sym value != 0 For a local object or function symbol, we expect that the section offset, sym.st_value, be 0 because we used -ffunction-sections and -fdata-section during compile. If value != 0, it undermines assumptions we make and should return an error. Exceptions should be handled on a case by case basis, like __ksymtab_strings. 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 048b673a6..b85957d35 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -384,8 +384,10 @@ void kpatch_create_symbol_table(struct kpatch_elf *kelf) */ if ((sym->type == STT_FUNC || sym->type == STT_OBJECT) && - sym->sym.st_value == 0 && strcmp(sym->sec->name, "__ksymtab_strings")) { + if (sym->sym.st_value != 0) + ERROR("symbol %s at offset %lu within section %s, expected 0", + sym->name, sym->sym.st_value, sym->sec->name); sym->sec->sym = sym; } else if (sym->type == STT_SECTION) { sym->sec->secsym = sym; From e8fb5b1c9ffd9d4eaeb1721e08e7f7c75e860f5d Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Mon, 10 Mar 2014 14:58:16 -0500 Subject: [PATCH 3/3] fixup comment Signed-off-by: Seth Jennings --- kpatch-build/create-diff-object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index b85957d35..f2a128e16 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -899,8 +899,8 @@ void kpatch_generate_output(struct kpatch_elf *kelf, struct kpatch_elf **kelfout } /* - * Search symbol table for local functions whose sections are - * not included, and modify them to be non-local. + * Search symbol table for local functions and objects whose sections + * are not included, and modify them to be non-local. */ for_each_symbol(i, sym, &kelf->symbols) { if (i == 0)