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: 87196 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp663184qgi; Wed, 7 Dec 2016 20:24:46 -0800 (PST) X-Received: by 10.99.105.70 with SMTP id e67mr123801076pgc.99.1481171086771; Wed, 07 Dec 2016 20:24:46 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o187si26995929pga.227.2016.12.07.20.24.46; Wed, 07 Dec 2016 20:24:46 -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 S1753115AbcLHEYR (ORCPT + 25 others); Wed, 7 Dec 2016 23:24:17 -0500 Received: from alt42.smtp-out.videotron.ca ([23.233.128.29]:23047 "EHLO alt42.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbcLHEYP (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-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)