From patchwork Tue Mar 5 05:48:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10839047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8ABA14DE for ; Tue, 5 Mar 2019 05:51:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D74AB2BB98 for ; Tue, 5 Mar 2019 05:51:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53DB2BCA5; Tue, 5 Mar 2019 05:51:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D8C52BC80 for ; Tue, 5 Mar 2019 05:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbfCEFvN (ORCPT ); Tue, 5 Mar 2019 00:51:13 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:38856 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfCEFvN (ORCPT ); Tue, 5 Mar 2019 00:51:13 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x255mOrT002400; Tue, 5 Mar 2019 14:48:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x255mOrT002400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551764905; bh=upricv6fVewsTKjghecoorebp9rRB3J2zizg4F0dOiY=; h=From:To:Cc:Subject:Date:From; b=psm7CSLg9BijV5QYpGE7GbBhhpCAe6mQnyl8ySC3xeg5QAvvvV2LEjloeMRip4SuO 2kD4bgx5yeh6gsItH3WqMtheJsOinOTNWDSkqCaCHdapoi7PslPNlh1UyUqJQt42z3 fp0gYP6WGCbaZ7BtpQU0jH2CseNNfhqaCEdYBkjtGob5ziN5Lrq086s0RBMFlKaJWf wIsne5C7SFaF2Rrw26bvyNF2+KySQs3JU2Ckj2qIEsEEO1n2WLsH3MS+RDuw+DJ0Y0 AHoB6iwdxKKOQ2bjdDLI1Befkmb4Zqm2Ga+H85C09Z8gGDazZNktbbsBOjIZPd1CkG KeIp+b3UH59Fg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra Cc: Thomas Gleixner , Douglas Anderson , Robin Meijboom , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Linus Torvalds , Sam Ravnborg , linux-kbuild@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] tools: move initial declarations out of 'for' loop Date: Tue, 5 Mar 2019 14:48:14 +0900 Message-Id: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When I was trying to compile this code for hostprogs-y notation of Kbuild, I was hit by the following error. error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode This is because KBUILD_HOSTCFLAGS specifies -std=gnu89 whereas the tools Makefile compiles it with -std=gnu99. Of course, it would be possible to pass -std=gnu99 per file, but it shouldn't hurt to fix the C code. Signed-off-by: Masahiro Yamada --- tools/lib/subcmd/parse-options.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index dbb9efb..1bd858a2 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -630,6 +630,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o const char *const subcommands[], const char *usagestr[], int flags) { struct parse_opt_ctx_t ctx; + int i; /* build usage string if it's not provided */ if (subcommands && !usagestr[0]) { @@ -637,7 +638,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o astrcatf(&buf, "%s %s [] {", subcmd_config.exec_name, argv[0]); - for (int i = 0; subcommands[i]; i++) { + for (i = 0; subcommands[i]; i++) { if (i) astrcat(&buf, "|"); astrcat(&buf, subcommands[i]); @@ -663,7 +664,7 @@ int parse_options_subcommand(int argc, const char **argv, const struct option *o exit(130); case PARSE_OPT_LIST_SUBCMDS: if (subcommands) { - for (int i = 0; subcommands[i]; i++) + for (i = 0; subcommands[i]; i++) printf("%s ", subcommands[i]); } putchar('\n'); From patchwork Tue Mar 5 05:48:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10839049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B059214DE for ; Tue, 5 Mar 2019 05:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E6232BBF9 for ; Tue, 5 Mar 2019 05:51:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 922B82BE46; Tue, 5 Mar 2019 05:51:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C6A12BE39 for ; Tue, 5 Mar 2019 05:51:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbfCEFvQ (ORCPT ); Tue, 5 Mar 2019 00:51:16 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:38923 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbfCEFvP (ORCPT ); Tue, 5 Mar 2019 00:51:15 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x255mOrU002400; Tue, 5 Mar 2019 14:48:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x255mOrU002400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551764906; bh=DlyhqYro9PRu0qrY7RWF8lCRod8hQNrPuAp+sT2sllM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DW2LOFlaDxv4HLHO4dev3+zueBOI0AgAkAWHqnfdgLujx4ciMN8idX70sVMkt5BS0 7BMpWchM8gUCFhZEzrH0Jk8ARcHP/wt2BQRbf/NC7iPNmM62l5bF6JCdTViV0cVIvS Kde05GQtYFo74TFpNcp+zhV5ofeU9XMQ+/lRE60JCgL9d8i1fJH7TCKAgqKK7OR5AW JxHp9Np6/Kckbfs4500erUUOB8/TCGGkgICqvcKexzCxMxJDDt2GuScve0TxRbVYhA 3aX3SKmXCfufEfgcaGtKc+qKBVLA9Qn1LqPlh1PhgxOudD28vBH6j/l0mka+dcp+9i b/OjsfjWTq4Pw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra Cc: Thomas Gleixner , Douglas Anderson , Robin Meijboom , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Linus Torvalds , Sam Ravnborg , linux-kbuild@vger.kernel.org, Masahiro Yamada , linux-doc@vger.kernel.org, Jonathan Corbet , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] objtool: move stack-validation.txt to Documentation/ Date: Tue, 5 Mar 2019 14:48:15 +0900 Message-Id: <1551764896-8453-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> References: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the document to the standard Documentation/ directory instead of creating the same directory structure under objtool/. Signed-off-by: Masahiro Yamada --- {tools/objtool/Documentation => Documentation}/stack-validation.txt | 0 Documentation/x86/orc-unwinder.txt | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {tools/objtool/Documentation => Documentation}/stack-validation.txt (100%) diff --git a/tools/objtool/Documentation/stack-validation.txt b/Documentation/stack-validation.txt similarity index 100% rename from tools/objtool/Documentation/stack-validation.txt rename to Documentation/stack-validation.txt diff --git a/Documentation/x86/orc-unwinder.txt b/Documentation/x86/orc-unwinder.txt index cd4b29b..3aeff80 100644 --- a/Documentation/x86/orc-unwinder.txt +++ b/Documentation/x86/orc-unwinder.txt @@ -137,7 +137,7 @@ Unwinder implementation details Objtool generates the ORC data by integrating with the compile-time stack metadata validation feature, which is described in detail in -tools/objtool/Documentation/stack-validation.txt. After analyzing all +Documentation/stack-validation.txt. After analyzing all the code paths of a .o file, it creates an array of orc_entry structs, and a parallel array of instruction addresses associated with those structs, and writes them to the .orc_unwind and .orc_unwind_ip sections From patchwork Tue Mar 5 05:48:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10839051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A25C17E4 for ; Tue, 5 Mar 2019 05:51:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 668F92BE4F for ; Tue, 5 Mar 2019 05:51:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 647C62BE5D; Tue, 5 Mar 2019 05:51:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A61702BE4F for ; Tue, 5 Mar 2019 05:51:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727128AbfCEFvX (ORCPT ); Tue, 5 Mar 2019 00:51:23 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:38938 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727073AbfCEFvW (ORCPT ); Tue, 5 Mar 2019 00:51:22 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x255mOrV002400; Tue, 5 Mar 2019 14:48:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x255mOrV002400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1551764908; bh=U4tagWc0AgGmL8q9wck+LfW8WuxK4FEczZ1llFEiWSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DEdjknw/Xv8Q1D21LXlOQkgEprQ/aOX4PpHSz3NmuFClzCKhcrgQHTvQysARHC2M/ 4YD+pxCl4U/7QiFaJqgzg36YZ9OUGl6wxRFoql3p+mWcgaXf0TxeD+8eCx6CebJL22 byrmcofed26mPbRRmsk4nV3RwsHaEfDBJGQ5pqpU5FK7KkPbG016BOLuQvzDGAvdPC WT1rUjZWT33yUXg1JD4kiBbJMz4Wzm94jB0fLVO39LMG1c92IqCMQCsVz+cAfDYwMP 3pmrcrOfiaMfLCG+seD1l7a1VBO7Swd3ET5bVOfSaV+ZCkJlRNq8nLKpglVxAUf3JU e8kf3siNXDQVg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Ingo Molnar , Josh Poimboeuf , Peter Zijlstra Cc: Thomas Gleixner , Douglas Anderson , Robin Meijboom , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, Linus Torvalds , Sam Ravnborg , linux-kbuild@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Michal Marek Subject: [PATCH 3/3] objtool: move tools/objtool/ to scripts/objtool/ Date: Tue, 5 Mar 2019 14:48:16 +0900 Message-Id: <1551764896-8453-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> References: <1551764896-8453-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tools that are globally needed for building the kernel are supposed to be put in the scripts/ directory, but objtool is the exceptional one. People were confused by objtool's Makefile since most of tools run on the target whereas objtool runs on the host machine. Some time ago, Douglas Anderson suggested to move tools/objtool/ to scripts/tools/ (https://patchwork.kernel.org/patch/9983535/#20996057), but we did not go as far as submitting a patch at that time. Recently, Robin Meijboom reported that the generated files for objtool were never cleaned up. (https://patchwork.kernel.org/patch/10813797/) So, I looked into this to fix the distortion. Move tools/objtool/ to scripts/objtool/, and rewrite Makefiles in the Kbuild-ish manner. I also cleaned up the top-level Makefile by moving the libelf check scripts/objtool/Makefile. I see some benefits in this. [1] generated files under scripts/ are cleaned up by 'make mrproper' Currently, the generated files under tools/objtool/ are not cleaned up since the build system under tools/ is a complete different world. If we want to clean them up, it should be done by 'make mrproper' instead of 'make clean' since objtool is needed for building external modules. This commit naturally solves the issue since Kbuild cleans under scripts/ by 'make mrproper'. [2] build log looks nicer Currently, the build log under tools/objtool/ shows absolute paths, and displays 'DESCEND objtool' every time for incremental building. Switching over to the standard Kbuild scheme will improve the log. Before: DESCEND objtool HOSTCC /home/masahiro/workspace/linux/tools/objtool/fixdep.o HOSTLD /home/masahiro/workspace/linux/tools/objtool/fixdep-in.o LINK /home/masahiro/workspace/linux/tools/objtool/fixdep CC /home/masahiro/workspace/linux/tools/objtool/exec-cmd.o CC /home/masahiro/workspace/linux/tools/objtool/help.o CC /home/masahiro/workspace/linux/tools/objtool/pager.o CC /home/masahiro/workspace/linux/tools/objtool/parse-options.o CC /home/masahiro/workspace/linux/tools/objtool/run-command.o CC /home/masahiro/workspace/linux/tools/objtool/sigchain.o CC /home/masahiro/workspace/linux/tools/objtool/subcmd-config.o LD /home/masahiro/workspace/linux/tools/objtool/libsubcmd-in.o AR /home/masahiro/workspace/linux/tools/objtool/libsubcmd.a GEN /home/masahiro/workspace/linux/tools/objtool/arch/x86/lib/inat-tables.c CC /home/masahiro/workspace/linux/tools/objtool/arch/x86/decode.o LD /home/masahiro/workspace/linux/tools/objtool/arch/x86/objtool-in.o CC /home/masahiro/workspace/linux/tools/objtool/builtin-check.o CC /home/masahiro/workspace/linux/tools/objtool/builtin-orc.o CC /home/masahiro/workspace/linux/tools/objtool/check.o CC /home/masahiro/workspace/linux/tools/objtool/orc_gen.o CC /home/masahiro/workspace/linux/tools/objtool/orc_dump.o CC /home/masahiro/workspace/linux/tools/objtool/elf.o CC /home/masahiro/workspace/linux/tools/objtool/special.o CC /home/masahiro/workspace/linux/tools/objtool/objtool.o CC /home/masahiro/workspace/linux/tools/objtool/libstring.o CC /home/masahiro/workspace/linux/tools/objtool/str_error_r.o LD /home/masahiro/workspace/linux/tools/objtool/objtool-in.o LINK /home/masahiro/workspace/linux/tools/objtool/objtool After: HOSTCC scripts/objtool/builtin-check.o HOSTCC scripts/objtool/builtin-orc.o HOSTCC scripts/objtool/check.o HOSTCC scripts/objtool/orc_gen.o HOSTCC scripts/objtool/orc_dump.o HOSTCC scripts/objtool/elf.o HOSTCC scripts/objtool/special.o HOSTCC scripts/objtool/objtool.o HOSTCC scripts/objtool/libstring.o HOSTCC scripts/objtool/str_error_r.o HOSTCC scripts/objtool/exec-cmd.o HOSTCC scripts/objtool/pager.o HOSTCC scripts/objtool/parse-options.o HOSTCC scripts/objtool/run-command.o HOSTCC scripts/objtool/sigchain.o HOSTCC scripts/objtool/subcmd-config.o AWK scripts/objtool/arch/x86/lib/inat-tables.c HOSTCC scripts/objtool/arch/x86/decode.o HOSTLD scripts/objtool/objtool [3] simplify distro package script The special handling in scripts/package/buildeb is no longer needed since all host programs are copied to linux-headers packages. Suggested-by: Douglas Anderson Reported-by: Robin Meijboom Signed-off-by: Masahiro Yamada --- MAINTAINERS | 2 +- Makefile | 24 +-------- scripts/Makefile | 1 + scripts/Makefile.build | 4 +- {tools => scripts}/objtool/.gitignore | 1 - scripts/objtool/Makefile | 43 +++++++++++++++ {tools => scripts}/objtool/arch.h | 0 scripts/objtool/arch/x86/Makefile | 20 +++++++ {tools => scripts}/objtool/arch/x86/decode.c | 0 .../objtool/arch/x86/include/asm/inat.h | 0 .../objtool/arch/x86/include/asm/inat_types.h | 0 .../objtool/arch/x86/include/asm/insn.h | 0 .../objtool/arch/x86/include/asm/orc_types.h | 0 {tools => scripts}/objtool/arch/x86/lib/inat.c | 0 {tools => scripts}/objtool/arch/x86/lib/insn.c | 0 .../objtool/arch/x86/lib/x86-opcode-map.txt | 0 .../objtool/arch/x86/tools/gen-insn-attr-x86.awk | 0 {tools => scripts}/objtool/builtin-check.c | 0 {tools => scripts}/objtool/builtin-orc.c | 0 {tools => scripts}/objtool/builtin.h | 0 {tools => scripts}/objtool/cfi.h | 0 {tools => scripts}/objtool/check.c | 0 {tools => scripts}/objtool/check.h | 0 {tools => scripts}/objtool/elf.c | 0 {tools => scripts}/objtool/elf.h | 0 scripts/objtool/exec-cmd.c | 2 + scripts/objtool/libstring.c | 1 + {tools => scripts}/objtool/objtool.c | 0 {tools => scripts}/objtool/orc.h | 0 {tools => scripts}/objtool/orc_dump.c | 0 {tools => scripts}/objtool/orc_gen.c | 0 scripts/objtool/pager.c | 1 + scripts/objtool/parse-options.c | 2 + scripts/objtool/run-command.c | 2 + scripts/objtool/sigchain.c | 2 + {tools => scripts}/objtool/special.c | 0 {tools => scripts}/objtool/special.h | 0 scripts/objtool/str_error_r.c | 1 + scripts/objtool/subcmd-config.c | 1 + {tools => scripts}/objtool/sync-check.sh | 8 +-- {tools => scripts}/objtool/warn.h | 0 scripts/package/builddeb | 3 -- tools/objtool/Build | 22 -------- tools/objtool/Makefile | 63 ---------------------- tools/objtool/arch/x86/Build | 12 ----- 45 files changed, 84 insertions(+), 131 deletions(-) rename {tools => scripts}/objtool/.gitignore (83%) create mode 100644 scripts/objtool/Makefile rename {tools => scripts}/objtool/arch.h (100%) create mode 100644 scripts/objtool/arch/x86/Makefile rename {tools => scripts}/objtool/arch/x86/decode.c (100%) rename {tools => scripts}/objtool/arch/x86/include/asm/inat.h (100%) rename {tools => scripts}/objtool/arch/x86/include/asm/inat_types.h (100%) rename {tools => scripts}/objtool/arch/x86/include/asm/insn.h (100%) rename {tools => scripts}/objtool/arch/x86/include/asm/orc_types.h (100%) rename {tools => scripts}/objtool/arch/x86/lib/inat.c (100%) rename {tools => scripts}/objtool/arch/x86/lib/insn.c (100%) rename {tools => scripts}/objtool/arch/x86/lib/x86-opcode-map.txt (100%) rename {tools => scripts}/objtool/arch/x86/tools/gen-insn-attr-x86.awk (100%) rename {tools => scripts}/objtool/builtin-check.c (100%) rename {tools => scripts}/objtool/builtin-orc.c (100%) rename {tools => scripts}/objtool/builtin.h (100%) rename {tools => scripts}/objtool/cfi.h (100%) rename {tools => scripts}/objtool/check.c (100%) rename {tools => scripts}/objtool/check.h (100%) rename {tools => scripts}/objtool/elf.c (100%) rename {tools => scripts}/objtool/elf.h (100%) create mode 100644 scripts/objtool/exec-cmd.c create mode 100644 scripts/objtool/libstring.c rename {tools => scripts}/objtool/objtool.c (100%) rename {tools => scripts}/objtool/orc.h (100%) rename {tools => scripts}/objtool/orc_dump.c (100%) rename {tools => scripts}/objtool/orc_gen.c (100%) create mode 100644 scripts/objtool/pager.c create mode 100644 scripts/objtool/parse-options.c create mode 100644 scripts/objtool/run-command.c create mode 100644 scripts/objtool/sigchain.c rename {tools => scripts}/objtool/special.c (100%) rename {tools => scripts}/objtool/special.h (100%) create mode 100644 scripts/objtool/str_error_r.c create mode 100644 scripts/objtool/subcmd-config.c rename {tools => scripts}/objtool/sync-check.sh (62%) rename {tools => scripts}/objtool/warn.h (100%) delete mode 100644 tools/objtool/Build delete mode 100644 tools/objtool/Makefile delete mode 100644 tools/objtool/arch/x86/Build diff --git a/MAINTAINERS b/MAINTAINERS index dce5c09..2fd8b9d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10948,7 +10948,7 @@ OBJTOOL M: Josh Poimboeuf M: Peter Zijlstra S: Supported -F: tools/objtool/ +F: scripts/objtool/ OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER M: Frederic Barrat diff --git a/Makefile b/Makefile index d5713e7..4251aca 100644 --- a/Makefile +++ b/Makefile @@ -944,17 +944,6 @@ mod_sign_cmd = true endif export mod_sign_cmd -ifdef CONFIG_STACK_VALIDATION - has_libelf := $(call try-run,\ - echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0) - ifeq ($(has_libelf),1) - objtool_target := tools/objtool FORCE - else - SKIP_STACK_VALIDATION := 1 - export SKIP_STACK_VALIDATION - endif -endif - PHONY += prepare0 ifeq ($(KBUILD_EXTMOD),) @@ -1092,7 +1081,7 @@ prepare0: archprepare $(Q)$(MAKE) $(build)=. # All the preparing.. -prepare: prepare0 prepare-objtool +prepare: prepare0 # Support for using generic headers in asm-generic asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj @@ -1103,17 +1092,6 @@ asm-generic: uapi-asm-generic uapi-asm-generic: $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm -PHONY += prepare-objtool -prepare-objtool: $(objtool_target) -ifeq ($(SKIP_STACK_VALIDATION),1) -ifdef CONFIG_UNWINDER_ORC - @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 - @false -else - @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 -endif -endif - # Generate some files # --------------------------------------------------------------------------- diff --git a/scripts/Makefile b/scripts/Makefile index feb1f71..edb780f 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -36,6 +36,7 @@ PHONY += build_unifdef build_unifdef: $(obj)/unifdef @: +subdir-$(CONFIG_STACK_VALIDATION) += objtool subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_SECURITY_SELINUX) += selinux diff --git a/scripts/Makefile.build b/scripts/Makefile.build index fd03d60..ccf8310 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -206,9 +206,8 @@ endif # CC_USING_RECORD_MCOUNT endif # CONFIG_FTRACE_MCOUNT_RECORD ifdef CONFIG_STACK_VALIDATION -ifneq ($(SKIP_STACK_VALIDATION),1) -__objtool_obj := $(objtree)/tools/objtool/objtool +__objtool_obj := $(objtree)/scripts/objtool/objtool objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check) @@ -234,7 +233,6 @@ objtool_obj = $(if $(patsubst y%,, \ $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ $(__objtool_obj)) -endif # SKIP_STACK_VALIDATION endif # CONFIG_STACK_VALIDATION # Rebuild all objects when objtool changes, or is enabled/disabled. diff --git a/tools/objtool/.gitignore b/scripts/objtool/.gitignore similarity index 83% rename from tools/objtool/.gitignore rename to scripts/objtool/.gitignore index 914cff1..103ee54 100644 --- a/tools/objtool/.gitignore +++ b/scripts/objtool/.gitignore @@ -1,3 +1,2 @@ arch/x86/lib/inat-tables.c objtool -fixdep diff --git a/scripts/objtool/Makefile b/scripts/objtool/Makefile new file mode 100644 index 0000000..34aa625 --- /dev/null +++ b/scripts/objtool/Makefile @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: GPL-2.0 + +libelf-missing := $(call try-run,\ + echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,,1) + +$(if $(libelf-missing), \ +$(error "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel")) + +hostprogs-y := objtool +always := objtool sync-check + +HOSTLDLIBS_objtool := -lelf + +objtool-objs := \ + builtin-check.o \ + builtin-orc.o \ + check.o \ + orc_gen.o \ + orc_dump.o \ + elf.o \ + special.o \ + objtool.o \ + libstring.o \ + str_error_r.o \ + exec-cmd.o \ + pager.o \ + parse-options.o \ + run-command.o \ + sigchain.o \ + subcmd-config.o + +HOST_EXTRACFLAGS := \ + -I $(srctree)/tools/include \ + -I $(srctree)/tools/lib \ + -I $(srctree)/$(src)/arch/$(SRCARCH)/include \ + -Werror -Wno-switch-default -Wno-switch-enum -Wno-packed -g + +include $(srctree)/$(src)/arch/$(SRCARCH)/Makefile + +cmd_sync_check = $(CONFIG_SHELL) $(srctree)/$(src)/sync-check.sh + +$(obj)/sync-check: FORCE + $(call cmd,sync_check) diff --git a/tools/objtool/arch.h b/scripts/objtool/arch.h similarity index 100% rename from tools/objtool/arch.h rename to scripts/objtool/arch.h diff --git a/scripts/objtool/arch/x86/Makefile b/scripts/objtool/arch/x86/Makefile new file mode 100644 index 0000000..cb1515e --- /dev/null +++ b/scripts/objtool/arch/x86/Makefile @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 + +$(shell mkdir -p $(obj)/arch/$(SRCARCH)/lib) + +objtool-objs += arch/$(SRCARCH)/decode.o + +HOSTCFLAGS_decode.o := -I $(objtree)/$(obj)/arch/$(SRCARCH)/lib + +$(obj)/arch/$(SRCARCH)/decode.o: $(obj)/arch/$(SRCARCH)/lib/inat-tables.c + +inat_tables_script = $(srctree)/$(src)/arch/$(SRCARCH)/tools/gen-insn-attr-x86.awk +inat_tables_maps = $(srctree)/$(src)/arch/$(SRCARCH)/lib/x86-opcode-map.txt + +quiet_cmd_inat_table = AWK $@ + cmd_inat_table = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ + +$(obj)/arch/$(SRCARCH)/lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps) + $(call cmd,inat_table) + +clean-files += arch/$(SRCARCH)/lib/inat-tables.c diff --git a/tools/objtool/arch/x86/decode.c b/scripts/objtool/arch/x86/decode.c similarity index 100% rename from tools/objtool/arch/x86/decode.c rename to scripts/objtool/arch/x86/decode.c diff --git a/tools/objtool/arch/x86/include/asm/inat.h b/scripts/objtool/arch/x86/include/asm/inat.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/inat.h rename to scripts/objtool/arch/x86/include/asm/inat.h diff --git a/tools/objtool/arch/x86/include/asm/inat_types.h b/scripts/objtool/arch/x86/include/asm/inat_types.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/inat_types.h rename to scripts/objtool/arch/x86/include/asm/inat_types.h diff --git a/tools/objtool/arch/x86/include/asm/insn.h b/scripts/objtool/arch/x86/include/asm/insn.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/insn.h rename to scripts/objtool/arch/x86/include/asm/insn.h diff --git a/tools/objtool/arch/x86/include/asm/orc_types.h b/scripts/objtool/arch/x86/include/asm/orc_types.h similarity index 100% rename from tools/objtool/arch/x86/include/asm/orc_types.h rename to scripts/objtool/arch/x86/include/asm/orc_types.h diff --git a/tools/objtool/arch/x86/lib/inat.c b/scripts/objtool/arch/x86/lib/inat.c similarity index 100% rename from tools/objtool/arch/x86/lib/inat.c rename to scripts/objtool/arch/x86/lib/inat.c diff --git a/tools/objtool/arch/x86/lib/insn.c b/scripts/objtool/arch/x86/lib/insn.c similarity index 100% rename from tools/objtool/arch/x86/lib/insn.c rename to scripts/objtool/arch/x86/lib/insn.c diff --git a/tools/objtool/arch/x86/lib/x86-opcode-map.txt b/scripts/objtool/arch/x86/lib/x86-opcode-map.txt similarity index 100% rename from tools/objtool/arch/x86/lib/x86-opcode-map.txt rename to scripts/objtool/arch/x86/lib/x86-opcode-map.txt diff --git a/tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk b/scripts/objtool/arch/x86/tools/gen-insn-attr-x86.awk similarity index 100% rename from tools/objtool/arch/x86/tools/gen-insn-attr-x86.awk rename to scripts/objtool/arch/x86/tools/gen-insn-attr-x86.awk diff --git a/tools/objtool/builtin-check.c b/scripts/objtool/builtin-check.c similarity index 100% rename from tools/objtool/builtin-check.c rename to scripts/objtool/builtin-check.c diff --git a/tools/objtool/builtin-orc.c b/scripts/objtool/builtin-orc.c similarity index 100% rename from tools/objtool/builtin-orc.c rename to scripts/objtool/builtin-orc.c diff --git a/tools/objtool/builtin.h b/scripts/objtool/builtin.h similarity index 100% rename from tools/objtool/builtin.h rename to scripts/objtool/builtin.h diff --git a/tools/objtool/cfi.h b/scripts/objtool/cfi.h similarity index 100% rename from tools/objtool/cfi.h rename to scripts/objtool/cfi.h diff --git a/tools/objtool/check.c b/scripts/objtool/check.c similarity index 100% rename from tools/objtool/check.c rename to scripts/objtool/check.c diff --git a/tools/objtool/check.h b/scripts/objtool/check.h similarity index 100% rename from tools/objtool/check.h rename to scripts/objtool/check.h diff --git a/tools/objtool/elf.c b/scripts/objtool/elf.c similarity index 100% rename from tools/objtool/elf.c rename to scripts/objtool/elf.c diff --git a/tools/objtool/elf.h b/scripts/objtool/elf.h similarity index 100% rename from tools/objtool/elf.h rename to scripts/objtool/elf.h diff --git a/scripts/objtool/exec-cmd.c b/scripts/objtool/exec-cmd.c new file mode 100644 index 0000000..4a153ea --- /dev/null +++ b/scripts/objtool/exec-cmd.c @@ -0,0 +1,2 @@ +#define _GNU_SOURCE +#include "../../tools/lib/subcmd/exec-cmd.c" diff --git a/scripts/objtool/libstring.c b/scripts/objtool/libstring.c new file mode 100644 index 0000000..840c910c --- /dev/null +++ b/scripts/objtool/libstring.c @@ -0,0 +1 @@ +#include "../../tools/lib/string.c" diff --git a/tools/objtool/objtool.c b/scripts/objtool/objtool.c similarity index 100% rename from tools/objtool/objtool.c rename to scripts/objtool/objtool.c diff --git a/tools/objtool/orc.h b/scripts/objtool/orc.h similarity index 100% rename from tools/objtool/orc.h rename to scripts/objtool/orc.h diff --git a/tools/objtool/orc_dump.c b/scripts/objtool/orc_dump.c similarity index 100% rename from tools/objtool/orc_dump.c rename to scripts/objtool/orc_dump.c diff --git a/tools/objtool/orc_gen.c b/scripts/objtool/orc_gen.c similarity index 100% rename from tools/objtool/orc_gen.c rename to scripts/objtool/orc_gen.c diff --git a/scripts/objtool/pager.c b/scripts/objtool/pager.c new file mode 100644 index 0000000..88652da --- /dev/null +++ b/scripts/objtool/pager.c @@ -0,0 +1 @@ +#include "../../tools/lib/subcmd/pager.c" diff --git a/scripts/objtool/parse-options.c b/scripts/objtool/parse-options.c new file mode 100644 index 0000000..a9d29b4 --- /dev/null +++ b/scripts/objtool/parse-options.c @@ -0,0 +1,2 @@ +#define _GNU_SOURCE +#include "../../tools/lib/subcmd/parse-options.c" diff --git a/scripts/objtool/run-command.c b/scripts/objtool/run-command.c new file mode 100644 index 0000000..f37ca5e --- /dev/null +++ b/scripts/objtool/run-command.c @@ -0,0 +1,2 @@ +#define _GNU_SOURCE +#include "../../tools/lib/subcmd/run-command.c" diff --git a/scripts/objtool/sigchain.c b/scripts/objtool/sigchain.c new file mode 100644 index 0000000..a5ad9bf --- /dev/null +++ b/scripts/objtool/sigchain.c @@ -0,0 +1,2 @@ +#define _GNU_SOURCE +#include "../../tools/lib/subcmd/sigchain.c" diff --git a/tools/objtool/special.c b/scripts/objtool/special.c similarity index 100% rename from tools/objtool/special.c rename to scripts/objtool/special.c diff --git a/tools/objtool/special.h b/scripts/objtool/special.h similarity index 100% rename from tools/objtool/special.h rename to scripts/objtool/special.h diff --git a/scripts/objtool/str_error_r.c b/scripts/objtool/str_error_r.c new file mode 100644 index 0000000..a32f7ae --- /dev/null +++ b/scripts/objtool/str_error_r.c @@ -0,0 +1 @@ +#include "../../tools/lib/str_error_r.c" diff --git a/scripts/objtool/subcmd-config.c b/scripts/objtool/subcmd-config.c new file mode 100644 index 0000000..6834fd6 --- /dev/null +++ b/scripts/objtool/subcmd-config.c @@ -0,0 +1 @@ +#include "../../tools/lib/subcmd/subcmd-config.c" diff --git a/tools/objtool/sync-check.sh b/scripts/objtool/sync-check.sh similarity index 62% rename from tools/objtool/sync-check.sh rename to scripts/objtool/sync-check.sh index 1470e74..98d2c97 100755 --- a/tools/objtool/sync-check.sh +++ b/scripts/objtool/sync-check.sh @@ -16,11 +16,13 @@ check() { local file=$1 - diff $file ../../$file > /dev/null || - echo "Warning: synced file at 'tools/objtool/$file' differs from latest kernel version at '$file'" + diff $file scripts/objtool/$file > /dev/null || + echo "Warning: synced file at 'scripts/objtool/$file' differs from latest kernel version at '$file'" } -if [ ! -d ../../kernel ] || [ ! -d ../../tools ] || [ ! -d ../objtool ]; then +cd $srctree + +if [ ! -d kernel ] || [ ! -d scripts/objtool ]; then exit 0 fi diff --git a/tools/objtool/warn.h b/scripts/objtool/warn.h similarity index 100% rename from tools/objtool/warn.h rename to scripts/objtool/warn.h diff --git a/scripts/package/builddeb b/scripts/package/builddeb index f43a274..abed281 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -158,9 +158,6 @@ done (cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" (cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" (cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" -if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then - (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" -fi (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" diff --git a/tools/objtool/Build b/tools/objtool/Build deleted file mode 100644 index 749becd..0000000 --- a/tools/objtool/Build +++ /dev/null @@ -1,22 +0,0 @@ -objtool-y += arch/$(SRCARCH)/ -objtool-y += builtin-check.o -objtool-y += builtin-orc.o -objtool-y += check.o -objtool-y += orc_gen.o -objtool-y += orc_dump.o -objtool-y += elf.o -objtool-y += special.o -objtool-y += objtool.o - -objtool-y += libstring.o -objtool-y += str_error_r.o - -CFLAGS += -I$(srctree)/tools/lib - -$(OUTPUT)libstring.o: ../lib/string.c FORCE - $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) - -$(OUTPUT)str_error_r.o: ../lib/str_error_r.c FORCE - $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile deleted file mode 100644 index c9d038f..0000000 --- a/tools/objtool/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -include ../scripts/Makefile.include -include ../scripts/Makefile.arch - -ifeq ($(ARCH),x86_64) -ARCH := x86 -endif - -# always use the host compiler -HOSTCC ?= gcc -HOSTLD ?= ld -CC = $(HOSTCC) -LD = $(HOSTLD) -AR = ar - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(CURDIR))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -endif - -SUBCMD_SRCDIR = $(srctree)/tools/lib/subcmd/ -LIBSUBCMD_OUTPUT = $(if $(OUTPUT),$(OUTPUT),$(CURDIR)/) -LIBSUBCMD = $(LIBSUBCMD_OUTPUT)libsubcmd.a - -OBJTOOL := $(OUTPUT)objtool -OBJTOOL_IN := $(OBJTOOL)-in.o - -all: $(OBJTOOL) - -INCLUDES := -I$(srctree)/tools/include \ - -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ - -I$(srctree)/tools/objtool/arch/$(ARCH)/include -WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -CFLAGS += -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) -LDFLAGS += -lelf $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) - -# Allow old libelf to be used: -elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr) -CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) - -AWK = awk -export srctree OUTPUT CFLAGS SRCARCH AWK -include $(srctree)/tools/build/Makefile.include - -$(OBJTOOL_IN): fixdep FORCE - @$(MAKE) $(build)=objtool - -$(OBJTOOL): $(LIBSUBCMD) $(OBJTOOL_IN) - @$(CONFIG_SHELL) ./sync-check.sh - $(QUIET_LINK)$(CC) $(OBJTOOL_IN) $(LDFLAGS) -o $@ - - -$(LIBSUBCMD): fixdep FORCE - $(Q)$(MAKE) -C $(SUBCMD_SRCDIR) OUTPUT=$(LIBSUBCMD_OUTPUT) - -clean: - $(call QUIET_CLEAN, objtool) $(RM) $(OBJTOOL) - $(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete - $(Q)$(RM) $(OUTPUT)arch/x86/lib/inat-tables.c $(OUTPUT)fixdep - -FORCE: - -.PHONY: clean FORCE diff --git a/tools/objtool/arch/x86/Build b/tools/objtool/arch/x86/Build deleted file mode 100644 index b998412..0000000 --- a/tools/objtool/arch/x86/Build +++ /dev/null @@ -1,12 +0,0 @@ -objtool-y += decode.o - -inat_tables_script = arch/x86/tools/gen-insn-attr-x86.awk -inat_tables_maps = arch/x86/lib/x86-opcode-map.txt - -$(OUTPUT)arch/x86/lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps) - $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ - -$(OUTPUT)arch/x86/decode.o: $(OUTPUT)arch/x86/lib/inat-tables.c - -CFLAGS_decode.o += -I$(OUTPUT)arch/x86/lib