From patchwork Wed Nov 30 08:50:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 84973 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp138383qgi; Wed, 30 Nov 2016 00:51:06 -0800 (PST) X-Received: by 10.98.66.214 with SMTP id h83mr31945006pfd.67.1480495866728; Wed, 30 Nov 2016 00:51:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y90si34838946plh.249.2016.11.30.00.51.06; Wed, 30 Nov 2016 00:51:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757392AbcK3Iuu (ORCPT + 25 others); Wed, 30 Nov 2016 03:50:50 -0500 Received: from alt42.smtp-out.videotron.ca ([23.233.128.29]:61905 "EHLO alt42.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754740AbcK3Iuc (ORCPT ); Wed, 30 Nov 2016 03:50:32 -0500 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id C0aycC0bL6cTKC0azcRCg1; Wed, 30 Nov 2016 03:50:31 -0500 X-Authority-Analysis: v=2.1 cv=TfA2zUkh c=1 sm=1 tr=0 a=keA3yYpnlypCNW5BNWqu+w==:117 a=keA3yYpnlypCNW5BNWqu+w==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=L24OOQBejmoA:10 a=KKAkSRfTAAAA:8 a=I33oReO6csBFAOQZ_2cA:9 a=cvBusfyB2V15izCimMoJ:22 Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 3C1D02DA0595; Wed, 30 Nov 2016 03:50:28 -0500 (EST) From: Nicolas Pitre To: Russell King - ARM Linux , Nicholas Piggin , Michal Marek Cc: Arnd Bergmann , viro@zeniv.linux.org.uk, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] kbuild: improve EXPORT_SYMBOL() parsing from asm code Date: Wed, 30 Nov 2016 03:50:22 -0500 Message-Id: <1480495824-4151-2-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480495824-4151-1-git-send-email-nicolas.pitre@linaro.org> References: <1480495824-4151-1-git-send-email-nicolas.pitre@linaro.org> X-CMAE-Envelope: MS4wfPMMigN1loCBFrfBkUPujgnbJC9pfibn2q4P9jUh07rojGHFEL/dWhRpXV2b2L/AwudzTQIaZhPFwTDWKq7L6+xWLyL9TFXupsiRSoVpl//aqBOB+gcX nv1rxj8JYQ1NTZHgijGfgZO4nHXMDhv1rYQiCUYqfhlRpNor+0c3fCfKp/eMH7IZz8pWuyrKqEy82By7hsMIYl6nP5fXc4hWVqfEjc00+Rz2z/YONFJshdbw DAD/xDbLw4k13D+QX+RrkZFPog4cRdm5wAjY9ifTEZkapGKFHQREmkWCiif8GPIb9CqeYvCCfqPYI7yRSNmgt41iXuFVFTvnlSFVqX2SPBm9yRQQeAvE6Mpc 1pC//V0jhtmFaAiwdrGiSD3lHPqAsJk5dMIx0npn0+1VS4EsXgk1InSzqrQKcteZvi8sYupV29tucscgJ12Ka3Kw1sUFxSdKewcGmH3CWYqXDJfbVe8= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org First, make the asm-prototypes.h presence optional. The next patch will make it unneeded for modversion support. Use the -D__GENKSYMS__ like we do for .c files but to expand the EXPORT_SYMBOL macro using the preprocessor instead of a sed script. The preprocessor output parsing is then limited to a simpler filtering and made more robust against multiple assembly statements on a single line. Signed-off-by: Nicolas Pitre --- include/asm-generic/export.h | 9 +++++++++ scripts/Makefile.build | 20 ++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 63554e9f6e..39a19dc366 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -28,6 +28,8 @@ #define KSYM(name) name #endif +#if defined(__KERNEL__) && !defined(__GENKSYMS__) + /* * note on .section use: @progbits vs %progbits nastiness doesn't matter, * since we immediately emit into those sections anyway. @@ -82,6 +84,13 @@ KSYM(__kcrctab_\name): #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec #endif +#else /* __GENKSYMS__ */ + +/* create a preprocessor output suitable for cmd_gensymtypes_S */ +#define __EXPORT_SYMBOL(sym, val, sec) EXPORT_SYMBOL(sym) + +#endif /* __GENKSYMS__ */ + #define EXPORT_SYMBOL(name) \ __EXPORT_SYMBOL(name, KSYM_FUNC(KSYM(name)),) #define EXPORT_SYMBOL_GPL(name) \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 7675d11ee6..ebf6e08ae4 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -325,15 +325,15 @@ $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) # 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. +# to make the genksyms input. See also include/asm-generic/export.h. # # These mirror gensymtypes_c and co above, keep them in synch. cmd_gensymtypes_S = \ - (echo "\#include " ; \ - echo "\#include " ; \ - $(CPP) $(a_flags) $< | \ - grep "\<___EXPORT_SYMBOL\>" | \ - sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ + ( echo "\#include " ; \ + if [ -e $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h ]; \ + then echo "\#include "; fi; \ + $(CPP) -D__GENKSYMS__ $(a_flags) $< | tr ";" "\n" | \ + sed -n -e '/EXPORT_SYMBOL(/s/$$/;/p' ) | \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ $(GENKSYMS) $(if $(1), -T $(2)) \ $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ @@ -363,13 +363,6 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< else -ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) - -ifeq ($(ASM_PROTOTYPES),) -cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< - -else - # versioning matches the C process described above, with difference that # we parse asm-prototypes.h C header to get function definitions. @@ -387,7 +380,6 @@ cmd_modversions_S = \ mv -f $(@D)/.tmp_$(@F) $@; \ fi; endif -endif $(obj)/%.o: $(src)/%.S $(objtool_obj) FORCE $(call if_changed_rule,as_o_S)