diff options
Diffstat (limited to 'include/linux/module.h')
| -rw-r--r-- | include/linux/module.h | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index b29e7458b966..e7c6385c6683 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -58,6 +58,12 @@ struct module_attribute { | |||
| 58 | void (*free)(struct module *); | 58 | void (*free)(struct module *); |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | struct module_version_attribute { | ||
| 62 | struct module_attribute mattr; | ||
| 63 | const char *module_name; | ||
| 64 | const char *version; | ||
| 65 | }; | ||
| 66 | |||
| 61 | struct module_kobject | 67 | struct module_kobject |
| 62 | { | 68 | { |
| 63 | struct kobject kobj; | 69 | struct kobject kobj; |
| @@ -161,7 +167,28 @@ extern struct module __this_module; | |||
| 161 | Using this automatically adds a checksum of the .c files and the | 167 | Using this automatically adds a checksum of the .c files and the |
| 162 | local headers in "srcversion". | 168 | local headers in "srcversion". |
| 163 | */ | 169 | */ |
| 170 | |||
| 171 | #if defined(MODULE) || !defined(CONFIG_SYSFS) | ||
| 164 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) | 172 | #define MODULE_VERSION(_version) MODULE_INFO(version, _version) |
| 173 | #else | ||
| 174 | #define MODULE_VERSION(_version) \ | ||
| 175 | extern ssize_t __modver_version_show(struct module_attribute *, \ | ||
| 176 | struct module *, char *); \ | ||
| 177 | static struct module_version_attribute __modver_version_attr \ | ||
| 178 | __used \ | ||
| 179 | __attribute__ ((__section__ ("__modver"),aligned(sizeof(void *)))) \ | ||
| 180 | = { \ | ||
| 181 | .mattr = { \ | ||
| 182 | .attr = { \ | ||
| 183 | .name = "version", \ | ||
| 184 | .mode = S_IRUGO, \ | ||
| 185 | }, \ | ||
| 186 | .show = __modver_version_show, \ | ||
| 187 | }, \ | ||
| 188 | .module_name = KBUILD_MODNAME, \ | ||
| 189 | .version = _version, \ | ||
| 190 | } | ||
| 191 | #endif | ||
| 165 | 192 | ||
| 166 | /* Optional firmware file (or files) needed by the module | 193 | /* Optional firmware file (or files) needed by the module |
| 167 | * format is simply firmware file name. Multiple firmware | 194 | * format is simply firmware file name. Multiple firmware |
| @@ -308,6 +335,9 @@ struct module | |||
| 308 | /* The size of the executable code in each section. */ | 335 | /* The size of the executable code in each section. */ |
| 309 | unsigned int init_text_size, core_text_size; | 336 | unsigned int init_text_size, core_text_size; |
| 310 | 337 | ||
| 338 | /* Size of RO sections of the module (text+rodata) */ | ||
| 339 | unsigned int init_ro_size, core_ro_size; | ||
| 340 | |||
| 311 | /* Arch-specific module values */ | 341 | /* Arch-specific module values */ |
| 312 | struct mod_arch_specific arch; | 342 | struct mod_arch_specific arch; |
| 313 | 343 | ||
| @@ -517,7 +547,7 @@ static inline void __module_get(struct module *module) | |||
| 517 | #define symbol_put_addr(p) do { } while(0) | 547 | #define symbol_put_addr(p) do { } while(0) |
| 518 | 548 | ||
| 519 | #endif /* CONFIG_MODULE_UNLOAD */ | 549 | #endif /* CONFIG_MODULE_UNLOAD */ |
| 520 | int use_module(struct module *a, struct module *b); | 550 | int ref_module(struct module *a, struct module *b); |
| 521 | 551 | ||
| 522 | /* This is a #define so the string doesn't get put in every .o file */ | 552 | /* This is a #define so the string doesn't get put in every .o file */ |
| 523 | #define module_name(mod) \ | 553 | #define module_name(mod) \ |
| @@ -672,7 +702,6 @@ static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter) | |||
| 672 | { | 702 | { |
| 673 | return 0; | 703 | return 0; |
| 674 | } | 704 | } |
| 675 | |||
| 676 | #endif /* CONFIG_MODULES */ | 705 | #endif /* CONFIG_MODULES */ |
| 677 | 706 | ||
| 678 | #ifdef CONFIG_SYSFS | 707 | #ifdef CONFIG_SYSFS |
| @@ -687,6 +716,13 @@ extern int module_sysfs_initialized; | |||
| 687 | 716 | ||
| 688 | #define __MODULE_STRING(x) __stringify(x) | 717 | #define __MODULE_STRING(x) __stringify(x) |
| 689 | 718 | ||
| 719 | #ifdef CONFIG_DEBUG_SET_MODULE_RONX | ||
| 720 | extern void set_all_modules_text_rw(void); | ||
| 721 | extern void set_all_modules_text_ro(void); | ||
| 722 | #else | ||
| 723 | static inline void set_all_modules_text_rw(void) { } | ||
| 724 | static inline void set_all_modules_text_ro(void) { } | ||
| 725 | #endif | ||
| 690 | 726 | ||
| 691 | #ifdef CONFIG_GENERIC_BUG | 727 | #ifdef CONFIG_GENERIC_BUG |
| 692 | void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, | 728 | void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *, |
