Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool: Resurrect --backup option

The --backup option was removed with the following commit:

aa8b3e64fd39 ("objtool: Create backup on error and print args")

... which tied the backup functionality to --verbose, and only for
warnings/errors.

It's a bit inelegant and out of scope to tie that to --verbose.

Bring back the old --backup option, but with the new behavior: only on
warnings/errors, and print the args to make it easier to recreate.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+16 -16
+11 -14
tools/objtool/builtin-check.c
··· 92 92 93 93 OPT_GROUP("Options:"), 94 94 OPT_BOOLEAN(0, "backtrace", &opts.backtrace, "unwind on error"), 95 + OPT_BOOLEAN(0, "backup", &opts.backup, "create backup (.orig) file on warning/error"), 95 96 OPT_BOOLEAN(0, "dry-run", &opts.dryrun, "don't write modifications"), 96 97 OPT_BOOLEAN(0, "link", &opts.link, "object is a linked object"), 97 98 OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"), ··· 247 246 } 248 247 } 249 248 250 - void print_args(void) 249 + int make_backup(void) 251 250 { 252 - char *backup = NULL; 253 - 254 - if (opts.output || opts.dryrun) 255 - goto print; 251 + char *backup; 256 252 257 253 /* 258 254 * Make a backup before kbuild deletes the file so the error ··· 258 260 backup = malloc(strlen(objname) + strlen(ORIG_SUFFIX) + 1); 259 261 if (!backup) { 260 262 ERROR_GLIBC("malloc"); 261 - goto print; 263 + return 1; 262 264 } 263 265 264 266 strcpy(backup, objname); 265 267 strcat(backup, ORIG_SUFFIX); 266 - if (copy_file(objname, backup)) { 267 - backup = NULL; 268 - goto print; 269 - } 268 + if (copy_file(objname, backup)) 269 + return 1; 270 270 271 - print: 272 271 /* 273 - * Print the cmdline args to make it easier to recreate. If '--output' 274 - * wasn't used, add it to the printed args with the backup as input. 272 + * Print the cmdline args to make it easier to recreate. 275 273 */ 274 + 276 275 fprintf(stderr, "%s", orig_argv[0]); 277 276 278 277 for (int i = 1; i < orig_argc; i++) { 279 278 char *arg = orig_argv[i]; 280 279 281 - if (backup && !strcmp(arg, objname)) 280 + /* Modify the printed args to use the backup */ 281 + if (!opts.output && !strcmp(arg, objname)) 282 282 fprintf(stderr, " %s -o %s", backup, objname); 283 283 else 284 284 fprintf(stderr, " %s", arg); 285 285 } 286 286 287 287 fprintf(stderr, "\n"); 288 + return 0; 288 289 } 289 290 290 291 int objtool_run(int argc, const char **argv)
+3 -1
tools/objtool/check.c
··· 4824 4824 if (opts.verbose) { 4825 4825 if (opts.werror && warnings) 4826 4826 WARN("%d warning(s) upgraded to errors", warnings); 4827 - print_args(); 4828 4827 disas_warned_funcs(file); 4829 4828 } 4829 + 4830 + if (opts.backup && make_backup()) 4831 + return 1; 4830 4832 4831 4833 return ret; 4832 4834 }
+2 -1
tools/objtool/include/objtool/builtin.h
··· 30 30 31 31 /* options: */ 32 32 bool backtrace; 33 + bool backup; 33 34 bool dryrun; 34 35 bool link; 35 36 bool mnop; ··· 49 48 50 49 int objtool_run(int argc, const char **argv); 51 50 52 - void print_args(void); 51 + int make_backup(void); 53 52 54 53 #endif /* _BUILTIN_H */