Commit f2d3a250 authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

objtool: Add --dry-run



Add a --dry-run argument to skip writing the modifications. This is
convenient for debugging.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154317.282720146@infradead.org
parent b44544fe
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
#include <objtool/objtool.h>

bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats,
     validate_dup, vmlinux, mcount, noinstr, backup, sls;
     validate_dup, vmlinux, mcount, noinstr, backup, sls, dryrun;

static const char * const check_usage[] = {
	"objtool check [<options>] file.o",
@@ -46,6 +46,7 @@ const struct option check_options[] = {
	OPT_BOOLEAN('M', "mcount", &mcount, "generate __mcount_loc"),
	OPT_BOOLEAN('B', "backup", &backup, "create .orig files before modification"),
	OPT_BOOLEAN('S', "sls", &sls, "validate straight-line-speculation"),
	OPT_BOOLEAN(0, "dry-run", &dryrun, "don't write the modifications"),
	OPT_END(),
};

+3 −0
Original line number Diff line number Diff line
@@ -1019,6 +1019,9 @@ int elf_write(struct elf *elf)
	struct section *sec;
	Elf_Scn *s;

	if (dryrun)
		return 0;

	/* Update changed relocation sections and section headers: */
	list_for_each_entry(sec, &elf->sections, list) {
		if (sec->changed) {
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@

extern const struct option check_options[];
extern bool no_fp, no_unreachable, retpoline, module, backtrace, uaccess, stats,
            validate_dup, vmlinux, mcount, noinstr, backup, sls;
            validate_dup, vmlinux, mcount, noinstr, backup, sls, dryrun;

extern int cmd_parse_options(int argc, const char **argv, const char * const usage[]);