From 37a66ee57cbd69799c2193e621f35b3f6346b274 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 15 Apr 2014 16:31:45 -0500 Subject: [PATCH 1/2] create-diff-object: show object name in log messages For log_normal and DIFF_FATAL messages, prefix them with the object name to give more context, which is useful for patches which change multiple objects. Also, no need to add the function and line number to DIFF_FATAL messages, as the error strings already give enough information. Example messages: meminfo.o: changed function: meminfo_proc_show cmdline.o: no changed functions were found --- kpatch-build/create-diff-object.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index 4d970cf..c5a8712 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -2,7 +2,7 @@ * create-diff-object.c * * Copyright (C) 2014 Seth Jennings - * Copyright (C) 2013 Josh Poimboeuf + * Copyright (C) 2013-2014 Josh Poimboeuf * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,18 +43,19 @@ #include #include #include +#include #define ERROR(format, ...) \ error(1, 0, "%s: %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__) #define DIFF_FATAL(format, ...) \ ({ \ - printf("%s:%d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + printf("%s: " format "\n", objname, ##__VA_ARGS__); \ error(2, 0, "unreconcilable difference"); \ }) #define log_debug(format, ...) log(DEBUG, format, ##__VA_ARGS__) -#define log_normal(format, ...) log(NORMAL, format, ##__VA_ARGS__) +#define log_normal(format, ...) log(NORMAL, "%s: " format, objname, ##__VA_ARGS__) #define log(level, format, ...) \ ({ \ @@ -62,6 +63,7 @@ printf(format, ##__VA_ARGS__); \ }) +char *objname; enum loglevel { DEBUG, @@ -1309,6 +1311,8 @@ int main(int argc, char *argv[]) elf_version(EV_CURRENT); + objname = basename(arguments.args[0]); + kelf_base = kpatch_elf_open(arguments.args[0]); kelf_patched = kpatch_elf_open(arguments.args[1]); outfile = arguments.args[2]; From 9b038039ddaf4b1b3536dfa1b1bb57991233be2e Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 15 Apr 2014 16:48:41 -0500 Subject: [PATCH 2/2] create-diff-object: removed unused function kpatch_find_changed_functions isn't called by anybody, so remove it. --- kpatch-build/create-diff-object.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index c5a8712..f4dd7eb 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -738,26 +738,6 @@ void kpatch_verify_patchability(struct kpatch_elf *kelf) DIFF_FATAL("changed section %s not selected for inclusion", sec->name); } -int kpatch_find_changed_functions(struct kpatch_elf *kelf) -{ - struct symbol *sym; - int i, changed = 0; - - for_each_symbol(i, sym, &kelf->symbols) { - if (sym->type != STT_FUNC) - continue; - if (sym->status == CHANGED) { - changed = 1; - printf("function %s has changed\n",sym->name); - } - } - - if (!changed) - printf("no changes found\n"); - - return changed; -} - #define inc_printf(fmt, ...) \ log_debug("%*s" fmt, recurselevel, "", ##__VA_ARGS__);