Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp633096ybk; Wed, 13 May 2020 09:01:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv+zV4VaouE2ffBEtfcwj2+sg0J5rBTWiBb37Bw0aaKmDrVfro9S3qHVqcbdvqOmtgZaQ8 X-Received: by 2002:a17:906:cce9:: with SMTP id ot41mr4395385ejb.349.1589385713962; Wed, 13 May 2020 09:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589385713; cv=none; d=google.com; s=arc-20160816; b=CEFAOSMTZOCNlIthMgD+FwIWROpCZ7Y3f0tv8F91fmrBT4/gF74XwCHmJv9wOyoeyZ rCcFh3z7lQAW3KehXAO2DW/jskT4+Wr/+HIvBVLAA1No2WSaaZf9FnfYk+AMeLNW151S 5VIZ1jIN6PysviDGQgSx/Cb8K8RZ9G5zK0NSnv7LFclAxRQBdps7dpd6RkH7Knj4aoQe IxVQHoo9UfGBoXylML3LneSqGikyPz+b/v0MoozyRPfuPFw7UMbcZ3eavoGnk6sqZf+0 ROr76/NHdmzlsVfBytyTjUCIFtnCHDo3PkPOoWqgaKQdlLtw/Xy9HJNsSdnhOryKneZQ EuJQ== 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=bbfIeOxJouDw/3jelLKDc6Bi6ByAoHUWwgYAY1VG51U=; b=nQG2ru8PHd+ugmLyAieeOimQlWKnhvGnbCyMVV/TbNYP/n8wmARniMtDyCKEAzXr+f bwH+3fYurN+L6KVWZ91yTqHlEtA9BVoiMOARBDIpdU8AmQcDrCgorht+pKlzWvdtl0in knN9cSawi+kRb0UsGDb8/+bcdcFI2il5bLDsSLNALugeaP3/edFPg/uA4Z+0ps1qNQss Jcy6lTmIzjS9quDTyKQx5nLs5fAcUoI574MrsaZBeo01AjuUXOJLPMtm2tcaPjpn+DUV ksD5QRBZ9r9agnBsZPWDt46kbjNESqqGR9jd4PO+iQRmUbJva1Vv89qs0uGxUxPkZYWO UdMw== 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 y1si3760edm.362.2020.05.13.09.01.29; Wed, 13 May 2020 09:01:53 -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 S1730616AbgEMP7t (ORCPT + 99 others); Wed, 13 May 2020 11:59:49 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:21411 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729179AbgEMP7t (ORCPT ); Wed, 13 May 2020 11:59:49 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Wed, 13 May 2020 08:59:46 -0700 Received: from localhost (unknown [10.166.66.23]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 886901B8084; Wed, 13 May 2020 11:59:48 -0400 (EDT) Date: Wed, 13 May 2020 08:59:48 -0700 From: Matt Helsley To: Julien Thierry CC: , Josh Poimboeuf , Peter Zijlstra , Miroslav Benes , Steven Rostedt Subject: Re: [RFC][PATCH 4/5] objtool: Enable compilation of objtool for all architectures Message-ID: <20200513155948.GI9040@rlwimi.vmware.com> Mail-Followup-To: Matt Helsley , Julien Thierry , linux-kernel@vger.kernel.org, Josh Poimboeuf , Peter Zijlstra , Miroslav Benes , Steven Rostedt References: <9f709ea2ae66cc03b3ff3329baa8f670ccd0e368.1588888003.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 Tue, May 12, 2020 at 06:04:56PM +0100, Julien Thierry wrote: > Hi Matt, > > On 5/11/20 6:35 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 a "missing" architecture which contains weak definitions > > for tools that do not exist on all architectures. In this case the > > "check" and "orc" tools do not exist on all architectures. > > > > To test building for other architectures ($arch below): > > > > cd tools/objtool/arch > > ln -s missing $arch > > make O=build-$arch ARCH=$arch tools/objtool > > > > Since the stuff under arch/missing is only weak symbols to make up for > missing subcmd implementations, can we put everything in a file > subcmd_defaults.c (name up for debate!) that would be always be compiled an > linked. And some SUBCMD_XXX is set to "y", the corresponding object file > gets compiled and overrides the weak symbols from subcmd_defaults.c . Hmm, I like keeping them separated along similar lines to the other code because it makes it easier to see the intended correspondence and likely will keep the files more readable / smaller. I could just move them out of arch/missing and into missing_check.c and so forth. What do you think of that? > > diff --git a/tools/objtool/Build b/tools/objtool/Build > > index 66f44f5cd2a6..fb6e6faf6f10 100644 > > --- a/tools/objtool/Build > > +++ b/tools/objtool/Build > > @@ -1,11 +1,12 @@ > > objtool-y += arch/$(SRCARCH)/ > > + > > +objtool-$(SUBCMD_CHECK) += 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 > > I'm not convinced by the moving of special under arch/x86 and I didn't > understand it at first. > > I guess you did it because it is only used by the check subcmd, which is > currently only implemented by x86. Is that the reason? Yeah, that was the original reasoning and this is an artifact of the previous patch set. > I feel that the proper way to do it would be to leave special.c/h where they > are and have "objtool-$(SUBCMD_CHECK) += special.o". Unless there was some > other motivation for it. This makes sense. I'll incorporate that in the next posting. > > objtool-y += objtool.o > > objtool-y += libstring.o > > diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile > > index f591c4d1b6fe..8aac9e133188 100644 > > --- a/tools/objtool/Makefile > > +++ b/tools/objtool/Makefile > > @@ -45,7 +45,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 > > + > > +ifeq ($(SRCARCH),x86) > > + SUBCMD_CHECK := y > > + SUBCMD_ORC := y > > +else > > + SUBCMD_CHECK := n > > + SUBCMD_ORC := n > > +endif > > + > > Nit: Can we default all SUBCMD_* variables to 'n' outside a branch and then > individual arches override the relevant variables to 'y' in their "ifeq > ($SRCARCH, )" branch? Definitely -- I'll set them all to n above then we can just have one ifeq block per arch. Thanks for the Review! Cheers, -Matt Helsley