From patchwork Mon Oct 31 11:14:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 9405329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDB016022E for ; Mon, 31 Oct 2016 11:15:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6EA228DD0 for ; Mon, 31 Oct 2016 11:15:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8FC528DDD; Mon, 31 Oct 2016 11:15: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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 A759628DD0 for ; Mon, 31 Oct 2016 11:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937500AbcJaLPN (ORCPT ); Mon, 31 Oct 2016 07:15:13 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34611 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936345AbcJaLPM (ORCPT ); Mon, 31 Oct 2016 07:15:12 -0400 Received: by mail-pf0-f193.google.com with SMTP id y68so2654133pfb.1; Mon, 31 Oct 2016 04:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=9VL3tgrcw13oCPJ542yxBAVSXOzChzEZAa5sZEsqVVA=; b=qanN2HEkR0TY0G7NE7tswfM8+iuWELr3jDr3xayIrzsMnfWVw/+1j4lCPtQPz1TO7D wZp/yEq2AshDgE3PdtMN9cpb+uDAKAnIto57CWPeTBatEcwQJ+TNqNGwTVQerm+xPs2a JsaMt2C8YpJ1aXpAT6Asb2o2WWp8JupBIxduP1ANF/V37e2mVEDN3mZccZX9jBZ/p+zt gO9Gjx2r1AOjoGE+SABGXgpbhuTdsOmfG3/SMzqNmQDHhUL8KG42xuttyd1NqBoAUvHC P1oA9LOZY4VvTP92x4j21r1qaFFstU546inyTMCCSZkUafXqDF9BHBfGoJrt59idgFpB +1Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=9VL3tgrcw13oCPJ542yxBAVSXOzChzEZAa5sZEsqVVA=; b=SEuRRySROhYHlypgazhEQdTDtERPclzfEG/WKhT4vWFF4CQJ6LFKmXuigouDU7C5Ye ytA/2adyKZK07MdHmdKcE9OAoQ1iMRO6p20pL5ueEfzErHbEVJfUT5ILO+goIhCIjCzf 0aPTU6SnRNwqi6gGxsT7k6PH9wwiS49/jJaN+tvWR5HarwJP+d2ttLCWZOOUA75WOimJ bUKfIfY8LKMb9750RAyWLeRDrBEQRQpJPUueVyp+cswbuJXFdNQt7jk512gKfW0Ie5ZO cSIHxzPlv5FkmvpIY34DeFKl1j5tVMhhbKYm+DpWKUqjkYCsk7ln99zX2Cq0v9Jz3CBf FF0Q== X-Gm-Message-State: ABUngvdOds9ypVR7OUb1IH1UA8DOtC93SeLPbK2Vtcdk6OXPDgkMmVRMhLFT3Kqtkhn1Hw== X-Received: by 10.99.45.7 with SMTP id t7mr39721498pgt.86.1477912511079; Mon, 31 Oct 2016 04:15:11 -0700 (PDT) Received: from roar.ozlabs.ibm.com (57.48.218.139.dynamic.dsl.dv.iprimus.net.au. [139.218.48.57]) by smtp.gmail.com with ESMTPSA id yk6sm35223282pab.43.2016.10.31.04.15.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Oct 2016 04:15:10 -0700 (PDT) Date: Mon, 31 Oct 2016 22:14:45 +1100 From: Nicholas Piggin To: Michal Marek Cc: Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arch@vger.kernel.org, Al Viro Subject: Re: [PATCH 2/2] kbuild: modversions for exported asm symbols Message-ID: <20161031221445.34e50e69@roar.ozlabs.ibm.com> In-Reply-To: References: <20161015124352.10795-1-npiggin@gmail.com> <7315031.MmlhY1rulM@wuerfel> <20161020145827.453025a6@roar.ozlabs.ibm.com> <16513464.3RM484EDf1@wuerfel> Organization: IBM X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) 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 On Sat, 22 Oct 2016 17:36:34 +0200 Michal Marek wrote: > Dne 20.10.2016 v 10:03 Arnd Bergmann napsal(a): > > On Thursday, October 20, 2016 2:58:27 PM CEST Nicholas Piggin wrote: > >> > >> Yeah, I had the same idea as you and Michal too. It's conceptually nicer, > >> but in practice it turned into a mess. If some architectures wanted to start > >> protecting their .h files and including them into .S for the prototypes, we > >> could start parsing those too. Should we do the quick and dirty way for 4.9? > > > > Let's stay with your approach for now. > > Agreed. My patch 2/2 needs the following incremental patch applied. It is to preprocess the .S file properly as asm the same way the kernel build does, and then building the dummy C from there. Without this, we don't necessarily get proper symbol expansion or get conditional compilation, etc. With it, genksyms should see what the assembler sees. --- scripts/Makefile.build | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2e512a2..6beeb9e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -321,12 +321,19 @@ $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) # or a file that it includes, in order to get versioned symbols. We build a # dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from # the .S file (with trailing ';'), and run genksyms on that, to extract vers. +# +# This is convoluted. The .S file must first be preprocessed to run guards and +# expand names, then the resulting exports must be constructed into plain +# EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed +# to make the genksyms input. # # These mirror gensymtypes_c and co above, keep them in synch. cmd_gensymtypes_S = \ (echo "\#include " ; \ echo "\#include " ; \ - grep EXPORT_SYMBOL $< | sed 's/$$/;/' ) | \ + $(CPP) $(a_flags) $< | \ + grep ^___EXPORT_SYMBOL | \ + sed 's/___EXPORT_SYMBOL \([a-zA-Z0-9_]*\),.*/EXPORT_SYMBOL(\1);/' ) | \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ $(GENKSYMS) $(if $(1), -T $(2)) \ $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \