Re: [RFC 1/3] add support for exporting symbols from .S files

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Arnd Bergmann
Date: Tuesday, August 12, 2008 - 6:58 am

This makes it possible to export symbols from assembly files, instead
of having to export them through an extra ksyms.c file.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---

On Tuesday 12 August 2008, Stephen Rothwell wrote:

Ok, this version uses the .balign as suggested by rusty, and also
fixes building with modversions turned on, which did not work in the
first version.

	Arnd <><

--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -1,5 +1,7 @@
 #ifndef _LINUX_MODULE_H
 #define _LINUX_MODULE_H
+
+#ifndef __ASSEMBLY__
 /*
  * Dynamic loading of modules into the kernel.
  *
@@ -605,4 +607,72 @@ static inline void module_remove_modinfo_attrs(struct module *mod)
 
 #define __MODULE_STRING(x) __stringify(x)
 
+#else /* __ASSEMBLY__ */
+#include <asm/types.h>
+
+#ifdef CONFIG_MODULES
+.macro __EXPORT_SYMBOL sym section symtab strtab crctab crc
+	.section \section, "a", @progbits
+	.type \symtab, @object
+	.balign BITS_PER_LONG/8
+\symtab:
+	.ifeq BITS_PER_LONG - 32
+	.long \sym
+	.long \strtab
+	.else
+	.quad \sym
+	.quad \strtab
+	.endif
+	.size \symtab, . - \symtab
+	.previous
+
+	.section __ksymtab_strings, "a", @progbits
+	.type \strtab, @object
+\strtab:
+	.string "\sym"
+	.size \strtab, . - \strtab
+	.previous
+
+#ifdef CONFIG_MODVERSIONS
+	/*
+	 * Modversions doesn't work with assembly files,
+	 * so insert a dummy CRC.
+	 */
+	.section __kcrctab, "a", @progbits
+	.balign 4
+	.type \crctab, @object
+\crctab:
+	.long \crc
+	.size \crctab, . - \crctab
+	.set \crc, 0
+	.previous
+#endif
+	.endm
+
+#define EXPORT_SYMBOL(sym) \
+	 __EXPORT_SYMBOL sym, __ksymtab, __ksymtab_ ## sym, \
+		__kstrtab_ ## sym, __kcrctab_ ## sym, __crc_ ## sym
+#define EXPORT_SYMBOL_GPL(sym) \
+	 __EXPORT_SYMBOL sym, __ksymtab_gpl, __ksymtab_ ## sym, \
+		__kstrtab_ ## sym, __kcrctab_ ## sym, __crc_ ## sym
+#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
+	 __EXPORT_SYMBOL sym, __ksymtab_gpl_future, __ksymtab_ ## sym, \
+		__kstrtab_ ## sym, __kcrctab_ ## sym, __crc_ ## sym
+#define EXPORT_UNUSED_SYMBOL(sym) \
+	 __EXPORT_SYMBOL sym, __ksymtab_unused, __ksymtab_ ## sym, \
+		__kstrtab_ ## sym, __kcrctab_ ## sym, __crc_ ## sym
+#define EXPORT_UNUSED_SYMBOL_GPL(sym) \
+	 __EXPORT_SYMBOL sym, __ksymtab_unused_gpl, __ksymtab_ ## sym, \
+		__kstrtab_ ## sym, __kcrctab_ ## sym, __crc_ ## sym
+
+#else /* CONFIG_MODULES... */
+#define EXPORT_SYMBOL(sym)
+#define EXPORT_SYMBOL_GPL(sym)
+#define EXPORT_SYMBOL_GPL_FUTURE(sym)
+#define EXPORT_UNUSED_SYMBOL(sym)
+#define EXPORT_UNUSED_SYMBOL_GPL(sym)
+#endif /* !CONFIG_MODULES... */
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* _LINUX_MODULE_H */
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
RFC: killing ksyms.c, Arnd Bergmann, (Mon Aug 11, 7:06 am)
[RFC 1/3] add support for exporting symbols from .S files, Arnd Bergmann, (Mon Aug 11, 7:18 am)
[RFC 3/3] powerpc: remove ppc_ksyms.c, Arnd Bergmann, (Mon Aug 11, 7:25 am)
Re: [RFC 2/3] powerpc: export all symbols from the definit ..., Geert Uytterhoeven, (Mon Aug 11, 7:53 am)
Re: RFC: killing ksyms.c, Adrian Bunk, (Mon Aug 11, 8:03 am)
Re: [RFC 1/3] add support for exporting symbols from .S files, Stephen Rothwell, (Mon Aug 11, 11:43 pm)
Re: [RFC 1/3] add support for exporting symbols from .S files, Arnd Bergmann, (Tue Aug 12, 6:58 am)