diff options
Diffstat (limited to 'include/linux/module.h')
-rw-r--r-- | include/linux/module.h | 92 |
1 files changed, 14 insertions, 78 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index d9ca2d5dc6d..bbd77fa05b1 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
17 | #include <linux/moduleparam.h> | 17 | #include <linux/moduleparam.h> |
18 | #include <linux/tracepoint.h> | 18 | #include <linux/tracepoint.h> |
19 | #include <linux/export.h> | ||
19 | 20 | ||
20 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
21 | #include <asm/module.h> | 22 | #include <asm/module.h> |
@@ -25,21 +26,8 @@ | |||
25 | /* Not Yet Implemented */ | 26 | /* Not Yet Implemented */ |
26 | #define MODULE_SUPPORTED_DEVICE(name) | 27 | #define MODULE_SUPPORTED_DEVICE(name) |
27 | 28 | ||
28 | /* Some toolchains use a `_' prefix for all user symbols. */ | ||
29 | #ifdef CONFIG_SYMBOL_PREFIX | ||
30 | #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | ||
31 | #else | ||
32 | #define MODULE_SYMBOL_PREFIX "" | ||
33 | #endif | ||
34 | |||
35 | #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN | 29 | #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN |
36 | 30 | ||
37 | struct kernel_symbol | ||
38 | { | ||
39 | unsigned long value; | ||
40 | const char *name; | ||
41 | }; | ||
42 | |||
43 | struct modversion_info | 31 | struct modversion_info |
44 | { | 32 | { |
45 | unsigned long crc; | 33 | unsigned long crc; |
@@ -48,10 +36,18 @@ struct modversion_info | |||
48 | 36 | ||
49 | struct module; | 37 | struct module; |
50 | 38 | ||
39 | struct module_kobject { | ||
40 | struct kobject kobj; | ||
41 | struct module *mod; | ||
42 | struct kobject *drivers_dir; | ||
43 | struct module_param_attrs *mp; | ||
44 | }; | ||
45 | |||
51 | struct module_attribute { | 46 | struct module_attribute { |
52 | struct attribute attr; | 47 | struct attribute attr; |
53 | ssize_t (*show)(struct module_attribute *, struct module *, char *); | 48 | ssize_t (*show)(struct module_attribute *, struct module_kobject *, |
54 | ssize_t (*store)(struct module_attribute *, struct module *, | 49 | char *); |
50 | ssize_t (*store)(struct module_attribute *, struct module_kobject *, | ||
55 | const char *, size_t count); | 51 | const char *, size_t count); |
56 | void (*setup)(struct module *, const char *); | 52 | void (*setup)(struct module *, const char *); |
57 | int (*test)(struct module *); | 53 | int (*test)(struct module *); |
@@ -65,15 +61,9 @@ struct module_version_attribute { | |||
65 | } __attribute__ ((__aligned__(sizeof(void *)))); | 61 | } __attribute__ ((__aligned__(sizeof(void *)))); |
66 | 62 | ||
67 | extern ssize_t __modver_version_show(struct module_attribute *, | 63 | extern ssize_t __modver_version_show(struct module_attribute *, |
68 | struct module *, char *); | 64 | struct module_kobject *, char *); |
69 | 65 | ||
70 | struct module_kobject | 66 | extern struct module_attribute module_uevent; |
71 | { | ||
72 | struct kobject kobj; | ||
73 | struct module *mod; | ||
74 | struct kobject *drivers_dir; | ||
75 | struct module_param_attrs *mp; | ||
76 | }; | ||
77 | 67 | ||
78 | /* These are either module local, or the kernel's dummy ones. */ | 68 | /* These are either module local, or the kernel's dummy ones. */ |
79 | extern int init_module(void); | 69 | extern int init_module(void); |
@@ -96,11 +86,8 @@ void trim_init_extable(struct module *m); | |||
96 | extern const struct gtype##_id __mod_##gtype##_table \ | 86 | extern const struct gtype##_id __mod_##gtype##_table \ |
97 | __attribute__ ((unused, alias(__stringify(name)))) | 87 | __attribute__ ((unused, alias(__stringify(name)))) |
98 | 88 | ||
99 | extern struct module __this_module; | ||
100 | #define THIS_MODULE (&__this_module) | ||
101 | #else /* !MODULE */ | 89 | #else /* !MODULE */ |
102 | #define MODULE_GENERIC_TABLE(gtype,name) | 90 | #define MODULE_GENERIC_TABLE(gtype,name) |
103 | #define THIS_MODULE ((struct module *)0) | ||
104 | #endif | 91 | #endif |
105 | 92 | ||
106 | /* Generic info of form tag = "info" */ | 93 | /* Generic info of form tag = "info" */ |
@@ -216,52 +203,6 @@ struct module_use { | |||
216 | struct module *source, *target; | 203 | struct module *source, *target; |
217 | }; | 204 | }; |
218 | 205 | ||
219 | #ifndef __GENKSYMS__ | ||
220 | #ifdef CONFIG_MODVERSIONS | ||
221 | /* Mark the CRC weak since genksyms apparently decides not to | ||
222 | * generate a checksums for some symbols */ | ||
223 | #define __CRC_SYMBOL(sym, sec) \ | ||
224 | extern void *__crc_##sym __attribute__((weak)); \ | ||
225 | static const unsigned long __kcrctab_##sym \ | ||
226 | __used \ | ||
227 | __attribute__((section("___kcrctab" sec "+" #sym), unused)) \ | ||
228 | = (unsigned long) &__crc_##sym; | ||
229 | #else | ||
230 | #define __CRC_SYMBOL(sym, sec) | ||
231 | #endif | ||
232 | |||
233 | /* For every exported symbol, place a struct in the __ksymtab section */ | ||
234 | #define __EXPORT_SYMBOL(sym, sec) \ | ||
235 | extern typeof(sym) sym; \ | ||
236 | __CRC_SYMBOL(sym, sec) \ | ||
237 | static const char __kstrtab_##sym[] \ | ||
238 | __attribute__((section("__ksymtab_strings"), aligned(1))) \ | ||
239 | = MODULE_SYMBOL_PREFIX #sym; \ | ||
240 | static const struct kernel_symbol __ksymtab_##sym \ | ||
241 | __used \ | ||
242 | __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ | ||
243 | = { (unsigned long)&sym, __kstrtab_##sym } | ||
244 | |||
245 | #define EXPORT_SYMBOL(sym) \ | ||
246 | __EXPORT_SYMBOL(sym, "") | ||
247 | |||
248 | #define EXPORT_SYMBOL_GPL(sym) \ | ||
249 | __EXPORT_SYMBOL(sym, "_gpl") | ||
250 | |||
251 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) \ | ||
252 | __EXPORT_SYMBOL(sym, "_gpl_future") | ||
253 | |||
254 | |||
255 | #ifdef CONFIG_UNUSED_SYMBOLS | ||
256 | #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") | ||
257 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") | ||
258 | #else | ||
259 | #define EXPORT_UNUSED_SYMBOL(sym) | ||
260 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) | ||
261 | #endif | ||
262 | |||
263 | #endif | ||
264 | |||
265 | enum module_state | 206 | enum module_state |
266 | { | 207 | { |
267 | MODULE_STATE_LIVE, | 208 | MODULE_STATE_LIVE, |
@@ -582,11 +523,6 @@ extern void module_update_tracepoints(void); | |||
582 | extern int module_get_iter_tracepoints(struct tracepoint_iter *iter); | 523 | extern int module_get_iter_tracepoints(struct tracepoint_iter *iter); |
583 | 524 | ||
584 | #else /* !CONFIG_MODULES... */ | 525 | #else /* !CONFIG_MODULES... */ |
585 | #define EXPORT_SYMBOL(sym) | ||
586 | #define EXPORT_SYMBOL_GPL(sym) | ||
587 | #define EXPORT_SYMBOL_GPL_FUTURE(sym) | ||
588 | #define EXPORT_UNUSED_SYMBOL(sym) | ||
589 | #define EXPORT_UNUSED_SYMBOL_GPL(sym) | ||
590 | 526 | ||
591 | /* Given an address, look for it in the exception tables. */ | 527 | /* Given an address, look for it in the exception tables. */ |
592 | static inline const struct exception_table_entry * | 528 | static inline const struct exception_table_entry * |