From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Brendan Jackman <jackmanb@google.com>,
Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 10/22] objtool: Reduce CONFIG_OBJTOOL_WERROR verbosity
Date: Mon, 24 Mar 2025 14:56:00 -0700 [thread overview]
Message-ID: <d61df69f64b396fa6b2a1335588aad7a34ea9e71.1742852846.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1742852846.git.jpoimboe@kernel.org>
Remove the following from CONFIG_OBJTOOL_WERROR:
* backtrace
* "upgraded warnings to errors" message
* cmdline args
This makes the default output less cluttered and makes it easier to spot
the actual warnings. Note the above options are still are available
with --verbose or OBJTOOL_VERBOSE=1.
Also, do the cmdline arg printing on all warnings, regardless of werror.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
scripts/Makefile.lib | 2 +-
tools/objtool/builtin-check.c | 113 ++++++++++++------------
tools/objtool/check.c | 23 ++---
tools/objtool/include/objtool/builtin.h | 6 +-
4 files changed, 73 insertions(+), 71 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 99e281966ba3..cdf45722626c 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -277,7 +277,7 @@ objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) += --static-call
objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) += --uaccess
objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable
objtool-args-$(CONFIG_PREFIX_SYMBOLS) += --prefix=$(CONFIG_FUNCTION_PADDING_BYTES)
-objtool-args-$(CONFIG_OBJTOOL_WERROR) += --Werror --backtrace
+objtool-args-$(CONFIG_OBJTOOL_WERROR) += --Werror
objtool-args = $(objtool-args-y) \
$(if $(delay-objtool), --link) \
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index c973a751fb7d..2bdff910430e 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -15,8 +15,11 @@
#include <objtool/objtool.h>
#include <objtool/warn.h>
-const char *objname;
+#define ORIG_SUFFIX ".orig"
+int orig_argc;
+static char **orig_argv;
+const char *objname;
struct opts opts;
static const char * const check_usage[] = {
@@ -224,39 +227,73 @@ static int copy_file(const char *src, const char *dst)
return 0;
}
-static char **save_argv(int argc, const char **argv)
+static void save_argv(int argc, const char **argv)
{
- char **orig_argv;
-
orig_argv = calloc(argc, sizeof(char *));
if (!orig_argv) {
WARN_GLIBC("calloc");
- return NULL;
+ exit(1);
}
for (int i = 0; i < argc; i++) {
orig_argv[i] = strdup(argv[i]);
if (!orig_argv[i]) {
WARN_GLIBC("strdup(%s)", orig_argv[i]);
- return NULL;
+ exit(1);
}
};
-
- return orig_argv;
}
-#define ORIG_SUFFIX ".orig"
+void print_args(void)
+{
+ char *backup = NULL;
+
+ if (opts.output || opts.dryrun)
+ goto print;
+
+ /*
+ * Make a backup before kbuild deletes the file so the error
+ * can be recreated without recompiling or relinking.
+ */
+ backup = malloc(strlen(objname) + strlen(ORIG_SUFFIX) + 1);
+ if (!backup) {
+ WARN_GLIBC("malloc");
+ goto print;
+ }
+
+ strcpy(backup, objname);
+ strcat(backup, ORIG_SUFFIX);
+ if (copy_file(objname, backup)) {
+ backup = NULL;
+ goto print;
+ }
+
+print:
+ /*
+ * Print the cmdline args to make it easier to recreate. If '--output'
+ * wasn't used, add it to the printed args with the backup as input.
+ */
+ fprintf(stderr, "%s", orig_argv[0]);
+
+ for (int i = 1; i < orig_argc; i++) {
+ char *arg = orig_argv[i];
+
+ if (backup && !strcmp(arg, objname))
+ fprintf(stderr, " %s -o %s", backup, objname);
+ else
+ fprintf(stderr, " %s", arg);
+ }
+
+ fprintf(stderr, "\n");
+}
int objtool_run(int argc, const char **argv)
{
struct objtool_file *file;
- char *backup = NULL;
- char **orig_argv;
int ret = 0;
- orig_argv = save_argv(argc, argv);
- if (!orig_argv)
- return 1;
+ orig_argc = argc;
+ save_argv(argc, argv);
cmd_parse_options(argc, argv, check_usage);
@@ -279,59 +316,19 @@ int objtool_run(int argc, const char **argv)
file = objtool_open_read(objname);
if (!file)
- goto err;
+ return 1;
if (!opts.link && has_multiple_files(file->elf)) {
WARN("Linked object requires --link");
- goto err;
+ return 1;
}
ret = check(file);
if (ret)
- goto err;
+ return ret;
if (!opts.dryrun && file->elf->changed && elf_write(file->elf))
- goto err;
+ return 1;
return 0;
-
-err:
- if (opts.dryrun)
- goto err_msg;
-
- if (opts.output) {
- unlink(opts.output);
- goto err_msg;
- }
-
- /*
- * Make a backup before kbuild deletes the file so the error
- * can be recreated without recompiling or relinking.
- */
- backup = malloc(strlen(objname) + strlen(ORIG_SUFFIX) + 1);
- if (!backup) {
- WARN_GLIBC("malloc");
- return 1;
- }
-
- strcpy(backup, objname);
- strcat(backup, ORIG_SUFFIX);
- if (copy_file(objname, backup))
- return 1;
-
-err_msg:
- fprintf(stderr, "%s", orig_argv[0]);
-
- for (int i = 1; i < argc; i++) {
- char *arg = orig_argv[i];
-
- if (backup && !strcmp(arg, objname))
- fprintf(stderr, " %s -o %s", backup, objname);
- else
- fprintf(stderr, " %s", arg);
- }
-
- fprintf(stderr, "\n");
-
- return 1;
}
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index fbe2a5ef2c40..03ec485a376a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4740,9 +4740,6 @@ int check(struct objtool_file *file)
free_insns(file);
- if (opts.verbose)
- disas_warned_funcs(file);
-
if (opts.stats) {
printf("nr_insns_visited: %ld\n", nr_insns_visited);
printf("nr_cfi: %ld\n", nr_cfi);
@@ -4751,19 +4748,25 @@ int check(struct objtool_file *file)
}
out:
+ if (!ret && !warnings)
+ return 0;
+
+ if (opts.verbose) {
+ if (opts.werror && warnings)
+ WARN("%d warning(s) upgraded to errors", warnings);
+ print_args();
+ disas_warned_funcs(file);
+ }
+
/*
* CONFIG_OBJTOOL_WERROR upgrades all warnings (and errors) to actual
* errors.
*
- * Note that even "fatal" type errors don't actually return an error
- * without CONFIG_OBJTOOL_WERROR. That probably needs improved at some
- * point.
+ * Note that even fatal errors don't yet actually return an error
+ * without CONFIG_OBJTOOL_WERROR. That will be fixed soon-ish.
*/
- if (opts.werror && (ret || warnings)) {
- if (warnings)
- WARN("%d warning(s) upgraded to errors", warnings);
+ if (opts.werror)
return 1;
- }
return 0;
}
diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
index 0fafd0f7a209..6b08666fa69d 100644
--- a/tools/objtool/include/objtool/builtin.h
+++ b/tools/objtool/include/objtool/builtin.h
@@ -43,8 +43,10 @@ struct opts {
extern struct opts opts;
-extern int cmd_parse_options(int argc, const char **argv, const char * const usage[]);
+int cmd_parse_options(int argc, const char **argv, const char * const usage[]);
-extern int objtool_run(int argc, const char **argv);
+int objtool_run(int argc, const char **argv);
+
+void print_args(void);
#endif /* _BUILTIN_H */
--
2.48.1
next prev parent reply other threads:[~2025-03-24 21:56 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 21:55 [PATCH 00/22] objtool: CONFIG_OBJTOOL_WERROR fixes and cleanups Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 01/22] objtool: Fix detection of consecutive jump tables Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] objtool: Fix detection of consecutive jump tables on Clang 20 tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 02/22] objtool: Warn when disabling unreachable warnings Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 03/22] objtool: Ignore entire functions rather than instructions Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 04/22] objtool: Fix X86_FEATURE_SMAP alternative handling Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 05/22] objtool: Fix CONFIG_OBJTOOL_WERROR for vmlinux.o Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 06/22] objtool: Fix init_module() handling Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 07/22] objtool: Silence more KCOV warnings Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 08/22] objtool: Properly disable uaccess validation Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:55 ` [PATCH 09/22] objtool: Improve error handling Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` Josh Poimboeuf [this message]
2025-03-25 8:35 ` [tip: objtool/urgent] objtool: Reduce CONFIG_OBJTOOL_WERROR verbosity tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 11/22] objtool: Fix up some outdated references to ENTRY/ENDPROC Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 12/22] objtool: Remove --no-unreachable for noinstr-only vmlinux.o runs Josh Poimboeuf
2025-03-25 8:35 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 13/22] objtool: Remove redundant opts.noinstr dependency Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 14/22] spi: amd: Fix out-of-bounds stack access in amd_set_spi_freq() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, " tip-bot2 for Josh Poimboeuf
2025-03-25 13:13 ` Mark Brown
2025-03-25 22:10 ` tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 15/22] nvmet: Fix out-of-bounds stack access in nvmet_ctrl_state_show() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, " tip-bot2 for Josh Poimboeuf
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-25 22:20 ` Chaitanya Kulkarni
2025-03-24 21:56 ` [PATCH 16/22] media: dib8000: Prevent divide-by-zero in dib8000_set_dds() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, " tip-bot2 for Josh Poimboeuf
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-25 22:42 ` Mauro Carvalho Chehab
2025-03-26 1:46 ` Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 17/22] panic: Disable SMAP in __stack_chk_fail() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, " tip-bot2 for Josh Poimboeuf
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 18/22] Input: cyapa - remove undefined behavior in cyapa_update_fw_store() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, Input: cyapa - Remove " tip-bot2 for Josh Poimboeuf
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 19/22] ASoC: codecs: wcd934x: Remove undefined behavior in wcd934x_slim_irq_handler() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, ASoC: codecs: wcd934x: Remove potential " tip-bot2 for Josh Poimboeuf
2025-03-25 11:32 ` Mark Brown
2025-03-25 11:36 ` Ingo Molnar
2025-03-25 13:12 ` Mark Brown
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 20/22] regulator: rk808: Remove undefined behavior in rk806_set_mode_dcdc() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, regulator: rk808: Remove potential " tip-bot2 for Josh Poimboeuf
2025-03-25 13:17 ` Mark Brown
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 21/22] pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config() Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, pwm: mediatek: Prevent theoretical " tip-bot2 for Josh Poimboeuf
2025-03-26 10:35 ` Uwe Kleine-König
2025-03-26 11:11 ` Peter Zijlstra
2025-03-27 5:44 ` Josh Poimboeuf
2025-03-27 8:27 ` Uwe Kleine-König
[not found] ` <m7pgkp3ueo7iqgqf74upjrihr3mpmb3sqhwegnjxxwsrgx2jsw@dnec5iqiyobh>
[not found] ` <Z-Uv60sD_S2xYVB1@gmail.com>
2025-03-27 18:14 ` Uwe Kleine-König
2025-03-27 21:21 ` Ingo Molnar
2025-03-28 10:24 ` Uwe Kleine-König
2025-03-28 13:45 ` Ingo Molnar
2025-03-28 18:19 ` Uwe Kleine-König
2025-03-25 22:09 ` tip-bot2 for Josh Poimboeuf
2025-03-27 11:06 ` tip-bot2 for Josh Poimboeuf
2025-03-24 21:56 ` [PATCH 22/22] lkdtm: Obfuscate do_nothing() pointer Josh Poimboeuf
2025-03-25 8:34 ` [tip: objtool/urgent] objtool, lkdtm: Obfuscate the " tip-bot2 for Josh Poimboeuf
2025-03-25 19:39 ` [PATCH 22/22] lkdtm: Obfuscate " Kees Cook
2025-03-25 22:09 ` [tip: objtool/urgent] objtool, lkdtm: Obfuscate the " tip-bot2 for Josh Poimboeuf
2025-03-27 11:06 ` tip-bot2 for Josh Poimboeuf
2025-03-28 13:48 ` tip-bot2 for Josh Poimboeuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d61df69f64b396fa6b2a1335588aad7a34ea9e71.1742852846.git.jpoimboe@kernel.org \
--to=jpoimboe@kernel.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mingo@kernel.org \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®