From patchwork Wed Nov 30 08:50:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 9453913 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 3F8D36071C for ; Wed, 30 Nov 2016 08:53:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A04928319 for ; Wed, 30 Nov 2016 08:53:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EC72283E8; Wed, 30 Nov 2016 08:53:23 +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 647A228319 for ; Wed, 30 Nov 2016 08:53:19 +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 1cC0c7-0004cu-Cd; Wed, 30 Nov 2016 08:51:39 +0000 Received: from alt32.smtp-out.videotron.ca ([24.53.0.21]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cC0bQ-00041B-OA for linux-arm-kernel@lists.infradead.org; Wed, 30 Nov 2016 08:51:01 +0000 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id C0ayc2HpVWjC4C0azckpBN; Wed, 30 Nov 2016 03:50:30 -0500 X-Authority-Analysis: v=2.1 cv=FfyXvMK6 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=8ubSwkDiYurDY74VSmoA:9 a=cvBusfyB2V15izCimMoJ:22 Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 50C762DA064A; Wed, 30 Nov 2016 03:50:28 -0500 (EST) From: Nicolas Pitre To: Russell King - ARM Linux , Nicholas Piggin , Michal Marek Subject: [PATCH 2/3] kbuild: make modversion for exported asm symbols more convivial Date: Wed, 30 Nov 2016 03:50:23 -0500 Message-Id: <1480495824-4151-3-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: MS4wfBNci9r7AaxAkfNEuKKqTTH6Q5jHmGaNfvrtLoLPUvopsqo36f47Ea5ZommeVsp7VeilNxu9I3moRICZoTSahW4cyeOJ5PUgHKYmY0ZezKTlrAP+c8lX rVF1Y8NKRvTl64TI/pj8wRWRK2Bmj1UT7gN8kQhk5Cg7/OuGTlnqHC+Z1USZfGkGdCh7Rytw1hRxNGsvchsXLoMjNsR52UxHCj5nOm5IJAzFEF9aNIf7PYAk Wbi+5ZjmMvlnceh5LzUqPJHj4y+X2YaKWv52ys6YQim+QxfgjmDhDjDTnl58DnEC6dqaVqFVdmW1xkj5t0++1eMqTJ2crAT2grkUVkiS7slSTH8ZC3zF6RFV bP58I/u9+wRnDshDEyO21ro2c9P+pV6K+vgEkBBLYGU2dYY3ub5pr/PPgl9+vtNa3lvx4E8+qQ4M4+eyfqpnUtoZViA/AdIZ3T57aMAL4o47r+jlnNk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161130_005057_003359_39277B5C X-CRM114-Status: GOOD ( 14.14 ) 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 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) \