Skip to contentSkip to conversation

module.h: split out the EXPORT_SYMBOL into export.h

PATCH Applied Masahiro Yamada 2 participants 2 messages May 9, 2020 – May 12, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 module.h: split out the EXPORT_SYMBOL into export.h

Do as Linux commit f50169324df4ad942e544386d136216c8617636a

---

Changes in v2:
- move THIS_MODULE

 include/linux/export.h | 39 +++++++++++++++++++++++++++++++++++++++
 include/module.h       | 28 +---------------------------
 2 files changed, 40 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/export.h
include/linux/export.h new file +39 -0
new file mode 100644
index 000000000..88d318bd8
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_EXPORT_H
+#define _LINUX_EXPORT_H
+
+#define THIS_MODULE	0
+
+#ifdef CONFIG_MODULES
+
+struct kernel_symbol
+{
+	unsigned long value;
+	const char *name;
+};
+
+/* For every exported symbol, place a struct in the __ksymtab section */
+#define __EXPORT_SYMBOL(sym, sec)				\
+	extern typeof(sym) sym;					\
+	static const char __ustrtab_##sym[]			\
+	__attribute__((section("__usymtab_strings")))		\
+	= MODULE_SYMBOL_PREFIX #sym;                    	\
+	static const struct kernel_symbol __usymtab_##sym	\
+	__used \
+	__attribute__((section("__usymtab" sec), unused))	\
+	= { (unsigned long)&sym, __ustrtab_##sym }
+
+#define EXPORT_SYMBOL(sym)					\
+	__EXPORT_SYMBOL(sym, "")
+
+#define EXPORT_SYMBOL_GPL(sym)					\
+	__EXPORT_SYMBOL(sym, "")
+
+#else
+
+#define EXPORT_SYMBOL(sym)
+#define EXPORT_SYMBOL_GPL(sym)
+
+#endif /* CONFIG_MODULES */
+
+#endif /* _LINUX_EXPORT_H */
include/module.h +1 -27
index abf740a78..cea8c2e18 100644
@@ -4,6 +4,7 @@
 
 #include <elf.h>
 #include <linux/compiler.h>
+#include <linux/export.h>
 #include <linux/list.h>
 
 #ifndef MODULE_SYMBOL_PREFIX
@@ -11,36 +12,12 @@
 #endif
 
 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
-#define THIS_MODULE	0
 
 #ifdef CONFIG_MODULES
 #include <asm/module.h>
 
-struct kernel_symbol
-{
-	unsigned long value;
-	const char *name;
-};
-
 struct module * load_module(void *mod_image, unsigned long len);
 
-/* For every exported symbol, place a struct in the __ksymtab section */
-#define __EXPORT_SYMBOL(sym, sec)				\
-	extern typeof(sym) sym;					\
-	static const char __ustrtab_##sym[]			\
-	__attribute__((section("__usymtab_strings")))		\
-	= MODULE_SYMBOL_PREFIX #sym;                    	\
-	static const struct kernel_symbol __usymtab_##sym	\
-	__used \
-	__attribute__((section("__usymtab" sec), unused))	\
-	= { (unsigned long)&sym, __ustrtab_##sym }
-
-#define EXPORT_SYMBOL(sym)					\
-	__EXPORT_SYMBOL(sym, "")
-
-#define EXPORT_SYMBOL_GPL(sym)					\
-	__EXPORT_SYMBOL(sym, "")
-
 struct module {
 	/* Unique handle for this module */
 	char name[MODULE_NAME_LEN];
@@ -74,9 +51,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
 		       unsigned int symindex,
 		       unsigned int relsec,
 		       struct module *mod);
-#else
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
 #endif /* CONFIG_MODULES */
 
 extern struct list_head module_list;
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 7 lines · Masahiro Yamada

Do as Linux commit f50169324df4ad942e544386d136216c8617636a

---

Changes in v2:
- move THIS_MODULE

Applied, thanks

Sascha

Quoted 119 lines
 include/linux/export.h | 39 +++++++++++++++++++++++++++++++++++++++
 include/module.h       | 28 +---------------------------
 2 files changed, 40 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/export.h
include/linux/export.h new file +39 -0
new file mode 100644
index 000000000..88d318bd8
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_EXPORT_H
+#define _LINUX_EXPORT_H
+
+#define THIS_MODULE	0
+
+#ifdef CONFIG_MODULES
+
+struct kernel_symbol
+{
+	unsigned long value;
+	const char *name;
+};
+
+/* For every exported symbol, place a struct in the __ksymtab section */
+#define __EXPORT_SYMBOL(sym, sec)				\
+	extern typeof(sym) sym;					\
+	static const char __ustrtab_##sym[]			\
+	__attribute__((section("__usymtab_strings")))		\
+	= MODULE_SYMBOL_PREFIX #sym;                    	\
+	static const struct kernel_symbol __usymtab_##sym	\
+	__used \
+	__attribute__((section("__usymtab" sec), unused))	\
+	= { (unsigned long)&sym, __ustrtab_##sym }
+
+#define EXPORT_SYMBOL(sym)					\
+	__EXPORT_SYMBOL(sym, "")
+
+#define EXPORT_SYMBOL_GPL(sym)					\
+	__EXPORT_SYMBOL(sym, "")
+
+#else
+
+#define EXPORT_SYMBOL(sym)
+#define EXPORT_SYMBOL_GPL(sym)
+
+#endif /* CONFIG_MODULES */
+
+#endif /* _LINUX_EXPORT_H */
include/module.h +1 -27
index abf740a78..cea8c2e18 100644
@@ -4,6 +4,7 @@
 
 #include <elf.h>
 #include <linux/compiler.h>
+#include <linux/export.h>
 #include <linux/list.h>
 
 #ifndef MODULE_SYMBOL_PREFIX
@@ -11,36 +12,12 @@
 #endif
 
 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
-#define THIS_MODULE	0
 
 #ifdef CONFIG_MODULES
 #include <asm/module.h>
 
-struct kernel_symbol
-{
-	unsigned long value;
-	const char *name;
-};
-
 struct module * load_module(void *mod_image, unsigned long len);
 
-/* For every exported symbol, place a struct in the __ksymtab section */
-#define __EXPORT_SYMBOL(sym, sec)				\
-	extern typeof(sym) sym;					\
-	static const char __ustrtab_##sym[]			\
-	__attribute__((section("__usymtab_strings")))		\
-	= MODULE_SYMBOL_PREFIX #sym;                    	\
-	static const struct kernel_symbol __usymtab_##sym	\
-	__used \
-	__attribute__((section("__usymtab" sec), unused))	\
-	= { (unsigned long)&sym, __ustrtab_##sym }
-
-#define EXPORT_SYMBOL(sym)					\
-	__EXPORT_SYMBOL(sym, "")
-
-#define EXPORT_SYMBOL_GPL(sym)					\
-	__EXPORT_SYMBOL(sym, "")
-
 struct module {
 	/* Unique handle for this module */
 	char name[MODULE_NAME_LEN];
@@ -74,9 +51,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
 		       unsigned int symindex,
 		       unsigned int relsec,
 		       struct module *mod);
-#else
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
 #endif /* CONFIG_MODULES */
 
 extern struct list_head module_list;
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox