Skip to content

create-diff-object: don't mark prefix symbols as changed - #1512

Draft
Zinkelburger wants to merge 1 commit into
dynup:masterfrom
Zinkelburger:prefix-symbols-not-changed
Draft

create-diff-object: don't mark prefix symbols as changed#1512
Zinkelburger wants to merge 1 commit into
dynup:masterfrom
Zinkelburger:prefix-symbols-not-changed

Conversation

@Zinkelburger

Copy link
Copy Markdown

When a symbol moves between sections -- out of an ignored section, or between text subsections -- kpatch_compare_correlated_symbol() marks it CHANGED. A function's _pfx/_cfi prefix symbol moves along with its parent, so it gets marked CHANGED as well.

Prefix symbols are padding, not independently patchable functions. kpatch_find_func_profiling_calls() already skips them, so they never have has_func_profiling set, and kpatch_check_func_profiling_calls() then rejects the build:

function __pfx_foo has no fentry/mcount call, unable to patch

Marking them CHANGED also emits a klp_func entry pointing at the padding instead of the function.

This shows up on x86_64 with CONFIG_CALL_PADDING when patching a function in a section that doesn't honor -ffunction-sections, such as .sched.text: dropping __sched from the function and adding
KPATCH_IGNORE_SECTION(".sched.text") moves both the function and its prefix symbol out of the shared section.

Leave the prefix symbol's status alone. It is still carried into the output through its parent function's sym->pfx link.

When a symbol moves between sections -- out of an ignored section, or
between text subsections -- kpatch_compare_correlated_symbol() marks it
CHANGED.  A function's __pfx_/__cfi_ prefix symbol moves along with its
parent, so it gets marked CHANGED as well.

Prefix symbols are padding, not independently patchable functions.
kpatch_find_func_profiling_calls() already skips them, so they never have
has_func_profiling set, and kpatch_check_func_profiling_calls() then
rejects the build:

  function __pfx_foo has no fentry/mcount call, unable to patch

Marking them CHANGED also emits a klp_func entry pointing at the padding
instead of the function.

This shows up on x86_64 with CONFIG_CALL_PADDING when patching a function
in a section that doesn't honor -ffunction-sections, such as .sched.text:
dropping __sched from the function and adding
KPATCH_IGNORE_SECTION(".sched.text") moves both the function and its
prefix symbol out of the shared section.

Leave the prefix symbol's status alone.  It is still carried into the
output through its parent function's sym->pfx link.

Signed-off-by: Andrew Bernal <andrewlbernal@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@joe-lawrence

Copy link
Copy Markdown
Contributor

Hi @Zinkelburger : thanks for the PR, though since we are mostly in maintenance-mode only for kpatch-build, what are the intended use-cases for this fix? And then, which approach is better #1512 or #1503 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants