Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp698122ybk; Wed, 20 May 2020 09:43:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv0ZUDWxLkiaAk5OC0VeogU1Nl6bse6ItnZo4k2diqSJ5l/31djcZLJXFXfSeEC14w3k0q X-Received: by 2002:a17:906:4bc1:: with SMTP id x1mr3474734ejv.13.1589992982884; Wed, 20 May 2020 09:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589992982; cv=none; d=google.com; s=arc-20160816; b=b4vItMx3Yj/CTREwumFX6R9foTBB4VAN/1U8jjPOq4WcQksBLM9tMxMx19FmMqU84y GyIs32cMdEFk36mlnO2DwybHDkG+LIraHYK/7x7gWZRegyIVlcXW4Q0423BTbJXs/mh7 M2HWK1VUFdVfMtIBusfGZC3D1MpK5LtmteiY8IB/Y8oxmmPTxD5MBZuATBNJcXU09JU3 cnugzAJuXnHkC4dZC1NssRom7UdupUweRTsMOyordVuaGuUnB2lsjJHixDeodck9Qwb5 FWUuuKnJUXSuAFZ49cm2l9jzCjGhIoYFBYlg+CVqgc5K+7mAcWSO/3GM3obXDd5kvRJd iJWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=3tifkdrIVbfbOj37IhtMBov6JKytrVGiAw9jHOmY0r4=; b=hOGW7YPXXNYs6EpDm5VFRIqcrdfKKCPEqBQTfSM1g17YgsvhDgoFME5q0V3PHyDkPd 2mGEXff2VmZLYdLEDe+6tsEywdu6sA2yjvmgscgcfBftzG1+Zqxe1GOX2gxgkvjmRrrZ Wt/34IUK+/1tiwMOQjCu0vcYFlawtzQNcp7/aULIlzZuIycryMZrbKCF7jepA5xYzuKW d5KvmdrxnRy+iPOtuwJbPBEWZSHCReLOK3FZbjwMzZY2PHTz+5WCQn6PdRT++ODVrh9F Ex2d5Hkykur2uHALBZm61jH02C2rMSKGhwEHEsRWOfa45M9spC4LiJJYqBXoZBib3JqL zvTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si1615188edw.590.2020.05.20.09.42.38; Wed, 20 May 2020 09:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbgETQlC (ORCPT + 99 others); Wed, 20 May 2020 12:41:02 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:48081 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726545AbgETQlC (ORCPT ); Wed, 20 May 2020 12:41:02 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Wed, 20 May 2020 09:40:59 -0700 Received: from localhost (unknown [10.200.192.41]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 1862D40448; Wed, 20 May 2020 09:41:02 -0700 (PDT) Date: Wed, 20 May 2020 09:41:01 -0700 From: Matt Helsley To: Julien Thierry CC: , Josh Poimboeuf , Peter Zijlstra , Miroslav Benes , Steven Rostedt Subject: Re: [PATCH 3/3] objtool: Enable compilation of objtool for all architectures Message-ID: <20200520164101.GU9040@rlwimi.vmware.com> Mail-Followup-To: Matt Helsley , Julien Thierry , linux-kernel@vger.kernel.org, Josh Poimboeuf , Peter Zijlstra , Miroslav Benes , Steven Rostedt References: <96252a8eee50710f4fe115ca516f0e6058b9f66b.1589913349.git.mhelsley@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: Received-SPF: None (EX13-EDG-OU-001.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 20, 2020 at 09:31:46AM +0100, Julien Thierry wrote: > > > On 5/19/20 9:55 PM, Matt Helsley wrote: > > objtool currently only compiles for x86 architectures. This is > > fine as it presently does not support tooling for other > > architectures. However, we would like to be able to convert other > > kernel tools to run as objtool sub commands because they too > > process ELF object files. This will allow us to convert tools > > such as recordmcount to use objtool's ELF code. > > > > Since much of recordmcount's ELF code is copy-paste code to/from > > a variety of other kernel tools (look at modpost for example) this > > means that if we can convert recordmcount we can convert more. > > > > We define "missing" weak definitions for subcommand entry functions > > and other weak definitions for shared functions critical to > > building existing subcommands. These return 127 when the command is > > missing which signify tools that do not exist on all architectures. > > In this case the "check" and "orc" tools do not exist on all > > architectures so we only add them for x86. Future changes adding > > support for "check", to arm64 for example, can then modify the > > SUBCMD_CHECK variable when building for arm64. > > > > objtool is not currently wired in to KConfig to be built for other > > architectures because it's not needed for those architectures and > > there are no commands it supports other than those for x86. As more > > command support is enabled on various architectures the necessary > > KConfig changes can be made (e.g. adding "STACK_VALIDATION") to > > trigger building objtool. > > > > Signed-off-by: Matt Helsley > > Cc: Julien Thierry > > --- > > tools/objtool/Build | 13 +++++++++---- > > tools/objtool/Makefile | 11 ++++++++++- > > tools/objtool/arch.h | 4 +++- > > tools/objtool/builtin-check.c | 2 +- > > tools/objtool/builtin-orc.c | 3 +-- > > tools/objtool/check.c | 4 ++-- > > tools/objtool/check.h | 4 ---- > > tools/objtool/objtool.h | 14 ++++++++++++++ > > tools/objtool/orc.h | 18 ------------------ > > tools/objtool/orc_dump.c | 3 ++- > > tools/objtool/orc_gen.c | 1 - > > tools/objtool/weak.c | 35 +++++++++++++++++++++++++++++++++++ > > 12 files changed, 77 insertions(+), 35 deletions(-) > > delete mode 100644 tools/objtool/orc.h > > create mode 100644 tools/objtool/weak.c > > > > diff --git a/tools/objtool/Build b/tools/objtool/Build > > index 66f44f5cd2a6..b7222d5cc7bc 100644 > > --- a/tools/objtool/Build > > +++ b/tools/objtool/Build > > @@ -1,11 +1,16 @@ > > objtool-y += arch/$(SRCARCH)/ > > + > > +objtool-y += weak.o > > + > > +objtool-$(SUBCMD_CHECK) += check.o > > +objtool-$(SUBCMD_CHECK) += special.o > > +objtool-$(SUBCMD_ORC) += check.o > > +objtool-$(SUBCMD_ORC) += orc_gen.o > > +objtool-$(SUBCMD_ORC) += orc_dump.o > > + > > 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 > > diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile > > index 6b91388aecbb..12686e2f1a56 100644 > > --- a/tools/objtool/Makefile > > +++ b/tools/objtool/Makefile > > @@ -46,7 +46,16 @@ elfshdr := $(shell echo '$(pound)include ' | $(CC) $(CFLAGS) -x c -E - > > CFLAGS += $(if $(elfshdr),,-DLIBELF_USE_DEPRECATED) > > AWK = awk > > -export srctree OUTPUT CFLAGS SRCARCH AWK > > + > > +SUBCMD_CHECK := n > > +SUBCMD_ORC := n > > + > > +ifeq ($(SRCARCH),x86) > > + SUBCMD_CHECK := y > > + SUBCMD_ORC := y > > +endif > > + > > +export srctree OUTPUT CFLAGS SRCARCH AWK SUBCMD_CHECK SUBCMD_ORC > > Nit: I was thinking, since the list of SUBCMD_* is only going to grow > maybe it would be nicer to have a single export line for the SUBCMD_* > variables and leave the export line of [srctree..AWK] untouched. That's a really good idea actually. Glad to see Josh included it in the changed patch. > > Just a suggestion, and only in case you respin this taking into account > Josh's comment. > > Otherwise things look good to me. Thanks for all the reviews and good ideas! Cheers, -Matt Helsley