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: 9453911 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 9E72F6071C for ; Wed, 30 Nov 2016 08:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BE6528409 for ; Wed, 30 Nov 2016 08:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D51928319; Wed, 30 Nov 2016 08:53:16 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BCDEF28319 for ; Wed, 30 Nov 2016 08:53:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cC0bs-0004VN-BG; Wed, 30 Nov 2016 08:51:24 +0000 Received: from alt42.smtp-out.videotron.ca ([23.233.128.29]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cC0bQ-00044p-NI for linux-arm-kernel@lists.infradead.org; Wed, 30 Nov 2016 08:50:59 +0000 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 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= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161130_005056_870417_8BB05227 X-CRM114-Status: GOOD ( 12.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)