From patchwork Thu Dec 8 04:24:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 9465745 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 2B1E360459 for ; Thu, 8 Dec 2016 04:24:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 037BB2852C for ; Thu, 8 Dec 2016 04:24:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A9528556; Thu, 8 Dec 2016 04:24:18 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 7670E2852C for ; Thu, 8 Dec 2016 04:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbcLHEYQ (ORCPT ); Wed, 7 Dec 2016 23:24:16 -0500 Received: from alt42.smtp-out.videotron.ca ([23.233.128.29]:23058 "EHLO alt42.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253AbcLHEYP (ORCPT ); Wed, 7 Dec 2016 23:24:15 -0500 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id EqFgc33gscMN9EqFhcUuui; Wed, 07 Dec 2016 23:24:14 -0500 X-Authority-Analysis: v=2.1 cv=YqOvP9sX 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=n5n_aSjo0skA: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 6C12D2DA05E0; Wed, 7 Dec 2016 23:24:12 -0500 (EST) From: Nicolas Pitre To: Michal Marek , Nicholas Piggin Cc: Arnd Bergmann , viro@zeniv.linux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] kbuild: improve EXPORT_SYMBOL() parsing from asm code Date: Wed, 7 Dec 2016 23:24:06 -0500 Message-Id: <1481171047-333-2-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481171047-333-1-git-send-email-nicolas.pitre@linaro.org> References: <1481171047-333-1-git-send-email-nicolas.pitre@linaro.org> X-CMAE-Envelope: MS4wfBKYepySI6TvcjHVFTW7xroxTfJ2opuuLVziryT6VpM+PCE2DH9mUZIycFXI9EJeJTFl0HTcHzl1Diu2RxqGYUuSIb72QRf5ln45MXo/ZY0J7l8tRZEj 9tmFgyOGAXceX5T8Kb7SQ9pyD8nkEt8uFrLAUf87uva1dfpBe6xqHOh1tCAjYzIaw6M51DJiSdKVvswdoi+BhrUdkdXHwRj0pom38MGoJGZjHTwmUMHNs5TM hg/+WaQDcHo4tAzwZjECgjk73zB1Yf16kehNXlmcVWf61o9wx9VhRLVqJlVKvjXknKdURYCzebEQcHOluHTkPLzo3p+EtPMGKzmmZV8W6Ar+L3mZ7uKg6O3X GB0oOHO28TQEcP7HQTA/GPjE/pgtRQ== 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 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)