From 4ba6f1fbc999c15d293679e3f72232419ce02167 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Thu, 24 Mar 2022 09:12:55 -0700 Subject: [PATCH] create-diff-object: include __dyndbg section when referenced by jump table If the only reference to the `__dyndbg` section is through a jump table entry, the section doesn't get included and the jump table relocations end up with a dangling reference to an UNDEF section symbol. Make sure jump table referenced dynamic debug symbols get their sections included. Fixes #1253. Signed-off-by: Josh Poimboeuf --- kpatch-build/create-diff-object.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 90a0d49..b15035b 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -2341,6 +2341,16 @@ static bool should_keep_jump_label(struct lookup_table *lookup, } /* The static key lives in vmlinux or the patch module itself */ + + /* + * If the jump label key lives in the '__dyndbg' section, make sure + * the section gets included, because we don't use klp relocs for + * dynamic debug symbols. For an example of such a key, see + * DYNAMIC_DEBUG_BRANCH(). + */ + if (dynamic_debug) + kpatch_include_symbol(key->sym); + return true; }