When deciding whether there's content to generate a payload also take into account whether special sections have changed. Initially account for changes to alternative related section to cause the generation of a livepatch.
Note that accounting for hook sections is already done by kpatch_include_hook_elements() when deciding whether there's changed content in the object file. .bugframe sections are also not accounted for since any section in a bugframe section will be accompanied by a change in the function the bugframe references (the placement of the BUG_INSTR will change in the caller function). Signed-off-by: Roger Pau Monné <roger....@citrix.com> --- create-diff-object.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/create-diff-object.c b/create-diff-object.c index 8bfb6bf92a1b..957631097b8a 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1663,6 +1663,28 @@ static int kpatch_include_hook_elements(struct kpatch_elf *kelf) return num_new_functions; } +static unsigned int include_special_sections(const struct kpatch_elf *kelf) +{ + const struct section *sec; + unsigned int nr = 0; + + /* + * Only account for changes in alternatives and exception table related + * sections. Hooks are already taken care of separately, and changes + * in bug_frame sections always go along with changes in the caller + * functions. + */ + list_for_each_entry(sec, &kelf->sections, list) + if (sec->status != SAME && + (!strcmp(sec->name, ".altinstructions") || + !strcmp(sec->name, ".altinstr_replacement") || + !strcmp(sec->name, ".ex_table") || + !strcmp(sec->name, ".fixup"))) + nr++; + + return nr; +} + static int kpatch_include_new_globals(struct kpatch_elf *kelf) { struct symbol *sym; @@ -2469,6 +2491,8 @@ int main(int argc, char *argv[]) kpatch_include_debug_sections(kelf_patched); log_debug("Include hook elements\n"); num_changed += kpatch_include_hook_elements(kelf_patched); + log_debug("Include special sections\n"); + num_changed += include_special_sections(kelf_patched); log_debug("num_changed = %d\n", num_changed); log_debug("Include new globals\n"); new_globals_exist = kpatch_include_new_globals(kelf_patched); -- 2.44.0