From a397818257a52ca0f64508a06a00749b9f54256a Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 29 Apr 2014 10:49:58 -0500 Subject: [PATCH] create-diff-object: better reachability error message If a patch changes a single function which is in a special section that we don't support, create-diff-object reports "no changed functions were found". Give a clearer error message in that case, by checking reachability errors before unchanged errors and by printing all reachability errors errors instead of the first one it encounters. Fixes #150. --- kpatch-build/create-diff-object.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 32a802e..c14c7c8 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -737,10 +737,16 @@ void kpatch_verify_patchability(struct kpatch_elf *kelf) { struct section *sec; int i; + int errs = 0; for_each_section(i, sec, &kelf->sections) - if (sec->status == CHANGED && !sec->include) - DIFF_FATAL("changed section %s not selected for inclusion", sec->name); + if (sec->status == CHANGED && !sec->include) { + log_normal("%s: changed section %s not selected for inclusion\n", + objname, sec->name); + errs++; + } + if (errs) + DIFF_FATAL("%d unsupported section change(s)", errs); } #define inc_printf(fmt, ...) \ @@ -1488,6 +1494,7 @@ int main(int argc, char *argv[]) struct kpatch_elf *kelf_base, *kelf_patched, *kelf_out; char *outfile; struct arguments arguments; + int num_changed; arguments.debug = 0; arguments.inventory = 0; @@ -1529,12 +1536,14 @@ int main(int argc, char *argv[]) kpatch_regenerate_parainstructions_sections(kelf_patched); kpatch_include_standard_sections(kelf_patched); - if (!kpatch_include_changed_functions(kelf_patched)) { + num_changed = kpatch_include_changed_functions(kelf_patched); + kpatch_dump_kelf(kelf_patched); + kpatch_verify_patchability(kelf_patched); + + if (!num_changed) { log_normal("no changed functions were found\n"); return 3; /* 1 is ERROR, 2 is DIFF_FATAL */ } - kpatch_dump_kelf(kelf_patched); - kpatch_verify_patchability(kelf_patched); /* Generate the output elf */ kpatch_generate_output(kelf_patched, &kelf_out);