mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: linux-arch@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 02/12] EXPORT_SYMBOL() for asm
Date: Fri, 29 Jan 2016 19:18:24 +0000	[thread overview]
Message-ID: <1454095114-4128-2-git-send-email-viro@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20160129191744.GB17997@ZenIV.linux.org.uk>

From: Al Viro <viro@zeniv.linux.org.uk>

Add asm-usable variants of EXPORT_SYMBOL/EXPORT_SYMBOL_GPL.  This
commit just adds the default implementation; most of the architectures
can simply add export.h to asm/Kbuild and start using <asm/export.h>
from assembler.  The area where the things might diverge from default
is the alignment; normally it's 8 bytes on 64bit targets and 4 on
32bit ones, both for unsigned long and for struct kernel_symbol.

Unfortunately, amd64 and m68k are unusual - m68k aligns to 2 bytes
(for both) and amd64 aligns struct kernel_symbol to 16 bytes.  For
those we'll need to have asm/export.h overriding the constants used
by generic version (KSYM_ALIGN and KCRC_ALIGN for kernel_symbol and
unsigned long resp.) and including asm-generic/export.h.

And no, __alignof__ would not do the trick - on amd64 __alignof__
of struct kernel_symbol is 8, not 16.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 include/asm-generic/export.h | 61 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 include/asm-generic/export.h

diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h
new file mode 100644
index 0000000..a1d44be
--- /dev/null
+++ b/include/asm-generic/export.h
@@ -0,0 +1,61 @@
+#ifndef __ASM_GENERIC_EXPORT_H
+#define __ASM_GENERIC_EXPORT_H
+
+#ifdef CONFIG_64BIT
+#define __put .quad
+#ifndef KSYM_ALIGN
+#define KSYM_ALIGN 8
+#endif
+#ifndef KCRC_ALIGN
+#define KCRC_ALIGN 8
+#endif
+#else
+#define __put .long
+#ifndef KSYM_ALIGN
+#define KSYM_ALIGN 4
+#endif
+#ifndef KCRC_ALIGN
+#define KCRC_ALIGN 4
+#endif
+#endif
+/*
+ * note on .section use: @progbits vs %progbits nastiness doesn't matter,
+ * since we immediately emit into those sections anyway.
+ */
+.macro __EXPORT_SYMBOL name,sec
+#ifdef CONFIG_MODULES
+	.globl __ksymtab_\name
+	.section ___ksymtab\sec+\name,"a"
+	.balign KSYM_ALIGN
+#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
+	___ksymtab_\name: __put _\name, ___kstrtab_\name
+#else
+	__ksymtab_\name: __put \name, __kstrtab_\name
+#endif
+	.previous
+	.section __ksymtab_strings,"a"
+#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
+	___kstrtab_\name: .asciz "_\name"
+#else
+	__kstrtab_\name: .asciz "\name"
+#endif
+	.previous
+#ifdef CONFIG_MODVERSIONS
+	.section ___kcrctab\sec+\name,"a"
+	.balign KCRC_ALIGN
+#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
+	___kcrctab_\name: __put ___crc_\name
+	.weak	___crc_\name
+#else
+	__kcrctab_\name: __put __crc_\name
+	.weak	__crc_\name
+#endif
+	.previous
+#endif
+#endif
+.endm
+#undef __put
+#define EXPORT_SYMBOL(name) __EXPORT_SYMBOL name
+#define EXPORT_SYMBOL_GPL(name) __EXPORT_SYMBOL name, _gpl
+
+#endif
-- 
2.1.4

  parent reply	other threads:[~2016-01-29 19:18 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29 19:17 [RFC][PATCHSET] allowing exports in *.S Al Viro
2016-01-29 19:18 ` [PATCH 01/12] [kbuild] handle exports in lib-y objects reliably Al Viro
2016-01-29 19:18 ` Al Viro [this message]
2016-01-29 21:06   ` [PATCH 02/12] EXPORT_SYMBOL() for asm Arnd Bergmann
2016-01-29 19:18 ` [PATCH 03/12] x86: move exports to actual definitions Al Viro
2016-02-01  8:12   ` Thomas Gleixner
2016-01-29 19:18 ` [PATCH 04/12] alpha: " Al Viro
2016-01-29 19:18 ` [PATCH 05/12] m68k: move exports to definitions Al Viro
2016-02-01 10:52   ` Geert Uytterhoeven
2016-02-01 12:18     ` Al Viro
2016-02-01 13:30       ` Geert Uytterhoeven
2016-02-01 14:53         ` Al Viro
2016-02-01 15:32           ` Geert Uytterhoeven
2016-01-29 19:18 ` [PATCH 06/12] s390: " Al Viro
2016-02-02 11:29   ` Heiko Carstens
2016-01-29 19:18 ` [PATCH 07/12] arm: " Al Viro
2016-01-29 19:18 ` [PATCH 08/12] ppc: " Al Viro
2016-01-29 19:18 ` [PATCH 09/12] sparc: " Al Viro
2016-01-30  7:08   ` David Miller
2016-01-29 19:18 ` [PATCH 10/12] ia64: " Al Viro
2016-01-29 19:18 ` [PATCH 11/12] [sparc] unify 32bit and 64bit string.h Al Viro
2016-01-30  7:08   ` David Miller
2016-01-29 19:18 ` [PATCH 12/12] sparc32: debride memcpy.S a bit Al Viro
2016-01-30  7:07   ` David Miller
2016-02-01 15:12 ` [PATCH 02/12] EXPORT_SYMBOL() for asm David Howells
2016-02-03 21:19 ` [RFC][PATCHSET v2] allowing exports in *.S Al Viro
2016-02-03 21:20   ` [PATCH v2 01/13] [kbuild] handle exports in lib-y objects reliably Al Viro
2016-02-04 22:33     ` Michal Marek
2016-02-05  0:18       ` Al Viro
2016-02-03 21:20   ` [PATCH v2 02/13] EXPORT_SYMBOL() for asm Al Viro
2016-02-04 18:06     ` Al Viro
2016-02-10 22:15     ` Nicolas Pitre
2016-02-03 21:20   ` [PATCH v2 03/13] x86: move exports to actual definitions Al Viro
2016-02-03 21:20   ` [PATCH v2 04/13] alpha: " Al Viro
2016-02-03 21:20   ` [PATCH v2 05/13] m68k: move exports to definitions Al Viro
2016-02-03 21:20   ` [PATCH v2 06/13] s390: " Al Viro
2016-02-03 21:20   ` [PATCH v2 07/13] arm: " Al Viro
2016-02-10 21:56     ` Nicolas Pitre
2016-02-03 21:20   ` [PATCH v2 08/13] ppc: " Al Viro
2016-02-03 21:20   ` [PATCH v2 09/13] ppc: get rid of unreachable abs() implementation Al Viro
2016-02-03 21:20   ` [PATCH v2 10/13] sparc: move exports to definitions Al Viro
2016-02-03 21:20   ` [PATCH v2 11/13] [sparc] unify 32bit and 64bit string.h Al Viro
2016-02-03 21:20   ` [PATCH v2 12/13] sparc32: debride memcpy.S a bit Al Viro
2016-02-03 21:20   ` [PATCH v2 13/13] ia64: move exports to definitions Al Viro
2016-08-02 14:01   ` [RFC][PATCHSET v2] allowing exports in *.S Michal Marek
2016-08-16  5:48     ` Michal Marek
2016-08-16  5:57       ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454095114-4128-2-git-send-email-viro@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome