From nobody Wed Feb 11 05:14:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0ECAC761A6 for ; Mon, 27 Mar 2023 16:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233131AbjC0QBp (ORCPT ); Mon, 27 Mar 2023 12:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232558AbjC0QBR (ORCPT ); Mon, 27 Mar 2023 12:01:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 318B061AA for ; Mon, 27 Mar 2023 09:00:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 6A302CE1895 for ; Mon, 27 Mar 2023 16:00:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8987AC433EF; Mon, 27 Mar 2023 16:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679932855; bh=bYtZM+fVMt9qB3FBfutuXiVUqLBuKD6bVnTa58kw0c4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fe77Ph3byGHORIBfErdD+mVoeIP2sM1YLoQpXcTU8uUmT0Mi0ltNPXcjNEqat5nfq vAlmx04lOmS0ABs1gV2fZ+GuQpzu+xcCiqXmXWbbhyvZgp7+p5bTf8PL5lnwqj+aVj c5/CNYra7ebHh5TyKogdYYCbayNuBbCBQjiK8j6VWTXq271ipXmDYY4MpR1WhgTleb dqbLjTvjW1YT5lvyUXviy2Ud2srDdPl5py7Ty3LmLUI/V/0YOm/a51ywXVhG1LmV6B JesC/cgl4tz2kHv3l46Wwe9v1BTKOak5ZpCG/hnliWuvoiC/PS0JPmOgYw+3oUXnc7 bT6z4qOAnJpmw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: [PATCH 1/5] objtool: Add '--verbose' option for disassembling affected functions Date: Mon, 27 Mar 2023 09:00:44 -0700 Message-Id: <217a005fe22f9d33f99fed499d6508af9f5cabd0.1679932620.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When a warning is associated with a function, add an option to disassemble that function. This makes it easier for reporters to submit the information needed to diagnose objtool warnings. Signed-off-by: Josh Poimboeuf --- tools/objtool/Documentation/objtool.txt | 5 ++++ tools/objtool/builtin-check.c | 1 + tools/objtool/include/objtool/builtin.h | 1 + tools/objtool/include/objtool/warn.h | 38 +++++++++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Docume= ntation/objtool.txt index 8e53fc6735ef..7c1a46af322f 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -244,6 +244,11 @@ To achieve the validation, objtool enforces the follow= ing rules: Objtool warnings ---------------- =20 +NOTE: When requesting help with an objtool warning, please re-run the +kernel build with `OBJTOOL_ARGS=3D"--verbose" make ` and send +the full warning output (including any function disassembly below the +warning) to the objtool maintainers. + For asm files, if you're getting an error which doesn't make sense, first make sure that the affected code follows the above rules. =20 diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index 7c175198d09f..b8de42f6778e 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -93,6 +93,7 @@ static const struct option check_options[] =3D { OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable= instruction' warnings"), OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses= in warnings"), OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"), + OPT_BOOLEAN('v', "verbose", &opts.verbose, "verbose warnings"), =20 OPT_END(), }; diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/includ= e/objtool/builtin.h index 2a108e648b7a..fcca6662c8b4 100644 --- a/tools/objtool/include/objtool/builtin.h +++ b/tools/objtool/include/objtool/builtin.h @@ -37,6 +37,7 @@ struct opts { bool no_unreachable; bool sec_address; bool stats; + bool verbose; }; =20 extern struct opts opts; diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/o= bjtool/warn.h index a3e79ae75f2e..b85aa440ee1f 100644 --- a/tools/objtool/include/objtool/warn.h +++ b/tools/objtool/include/objtool/warn.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include =20 @@ -41,6 +42,41 @@ static inline char *offstr(struct section *sec, unsigned= long offset) return str; } =20 +static inline void objdump_func(struct section *sec, unsigned long offset) +{ + struct symbol *sym =3D find_func_containing(sec, offset); + const char *script_relative =3D "scripts/objdump-func"; + bool is_text =3D (sec->sh.sh_flags & SHF_EXECINSTR); + char *cmd, *srctree, *script; + + if (is_text) + sym =3D find_func_containing(sec, offset); + if (!sym) + sym =3D find_symbol_containing(sec, offset); + if (!sym) + return; + + srctree =3D getenv("abs_srctree"); + if (!srctree) + return; + + script =3D malloc(strlen(srctree) + strlen(script_relative) + 2); + if (!script) + return; + + sprintf(script, "%s/%s", srctree, script_relative); + + if (access(script, X_OK)) + return; + + cmd =3D malloc(strlen(script) + strlen(objname) + strlen(sym->name) + 10); + if (!cmd) + return; + + sprintf(cmd, "%s %s %s 1>&2", script, objname, sym->name); + system(cmd); +} + #define WARN(format, ...) \ fprintf(stderr, \ "%s: warning: objtool: " format "\n", \ @@ -51,6 +87,8 @@ static inline char *offstr(struct section *sec, unsigned = long offset) char *_str =3D offstr(sec, offset); \ WARN("%s: " format, _str, ##__VA_ARGS__); \ free(_str); \ + if (opts.verbose) \ + objdump_func(sec, offset); \ }) =20 #define BT_FUNC(format, insn, ...) \ --=20 2.39.2