Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932421AbcLHEYT (ORCPT ); Wed, 7 Dec 2016 23:24:19 -0500 Received: from alt32.smtp-out.videotron.ca ([24.53.0.21]:18478 "EHLO alt32.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752647AbcLHEYP (ORCPT ); Wed, 7 Dec 2016 23:24:15 -0500 X-Authority-Analysis: v=2.1 cv=Gfm35VjL 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=8ubSwkDiYurDY74VSmoA:9 a=cvBusfyB2V15izCimMoJ:22 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 2/2] kbuild: make modversion for exported asm symbols more convivial Date: Wed, 7 Dec 2016 23:24:07 -0500 Message-Id: <1481171047-333-3-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: MS4wfIPR4eNup3ieQt2B9gTX8ik5ik8bkJkbqefFBqeptFaI6za9sy5/h66ZA24n69EHmwuKRAxQPAG6u0SHNC54uwCClV+pBWs/EI+RXzc8++gaxsFTnVXB Z71wNAcDCatCW6Mam0kwFY9OVG1HXqrBfXGaaAwfYY+En4YSoAYg+YIf9anUpUxr9AQeDc+teuGCpBb5cC4wfzw30gyHXlb/MfPkrM1xNJARzWU1ybeFzGiB KpqwB1ocmIZ47L3QR79WKHlAahj/vSDixQzttf5ieQtCphieDNgWyl1GNI+ULSd9qiUVvQSu0ZhkpLQp00y0fHqiyeGR7bYI0dzg4u7LTqLqIYA/4Nd87n0K Oaa+bRTXYBV8UyaXU1rO1YJACkBf6w== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4436 Lines: 89 Rather than having an asm-prototypes.h file where C prototypes for exported asm symbols are centralized, let's have some macros that can be used directly in the code where those symbols are exported for genksyms consumption. Either the prototype is provided directly if no include files has it, or the include file containing it is specified. Signed-off-by: Nicolas Pitre --- include/asm-generic/export.h | 15 +++++++++++++++ scripts/Makefile.build | 22 +++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 39a19dc366..83dda5f840 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -84,11 +84,26 @@ KSYM(__kcrctab_\name): #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec #endif +/* in the non genksyms case those are no-ops */ +#define SYMBOL_CPROTO(expr) +#define SYMBOL_CPROTO_INCLUDE(file) + #else /* __GENKSYMS__ */ /* create a preprocessor output suitable for cmd_gensymtypes_S */ #define __EXPORT_SYMBOL(sym, val, sec) EXPORT_SYMBOL(sym) +/* + * The cmd_gensymtypes_S kbuild command recognizes the following: + * + * Provide a C prototype for genksyms: SYMBOL_CPROTO(expr) + * example: SYMBOL_CPROTO(void foobar(int x, int y)) + * + * Specify an include file that contains C prototypes for genksyms: + * SYMBOL_CPROTO_INCLUDE(quoted_filename) + * example: SYMBOL_CPROTO_INCLUDE() + */ + #endif /* __GENKSYMS__ */ #define EXPORT_SYMBOL(name) \ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index ebf6e08ae4..58ebc4b15d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -317,24 +317,32 @@ modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) -# .S file exports must have their C prototypes defined in asm/asm-prototypes.h -# 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. +# In order to get versioned symbols, .S file exports must have their C prototypes: +# - defined in asm/asm-prototypes.h or a file that it includes, or +# - provided in a file specified by SYMBOL_CPROTO_INCLUDE(), or +# - specified directly by SYMBOL_CPROTO(). +# 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. See also include/asm-generic/export.h. # +# The -Ulinux is necessary otherwise SYMBOL_CPROTO_INCLUDE() +# is turned into #include <1/bitops.h> due to "linux" being defined to 1. +# # These mirror gensymtypes_c and co above, keep them in synch. cmd_gensymtypes_S = \ ( 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 - | \ + $(CPP) -D__GENKSYMS__ $(a_flags) -Ulinux $< | tr ";" "\n" | \ + sed -n -e '/EXPORT_SYMBOL(/s/$$/;/p' \ + -e 's/SYMBOL_CPROTO(\(.*\))/\1;/p' \ + -e 's/SYMBOL_CPROTO_INCLUDE(\(.*\))/\#include \1/p' ) | \ + $(CPP) -D__GENKSYMS__ -I$(@D) $(c_flags) -xc - | \ $(GENKSYMS) $(if $(1), -T $(2)) \ $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ $(if $(KBUILD_PRESERVE),-p) \ -- 2.7.4