aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/module.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/module.h')
-rw-r--r--include/linux/module.h63
1 files changed, 55 insertions, 8 deletions
diff --git a/include/linux/module.h b/include/linux/module.h
index 22d9878e868c..627ac082e2a6 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -248,6 +248,10 @@ struct module
248 const unsigned long *crcs; 248 const unsigned long *crcs;
249 unsigned int num_syms; 249 unsigned int num_syms;
250 250
251 /* Kernel parameters. */
252 struct kernel_param *kp;
253 unsigned int num_kp;
254
251 /* GPL-only exported symbols. */ 255 /* GPL-only exported symbols. */
252 unsigned int num_gpl_syms; 256 unsigned int num_gpl_syms;
253 const struct kernel_symbol *gpl_syms; 257 const struct kernel_symbol *gpl_syms;
@@ -355,6 +359,8 @@ struct module
355#define MODULE_ARCH_INIT {} 359#define MODULE_ARCH_INIT {}
356#endif 360#endif
357 361
362extern struct mutex module_mutex;
363
358/* FIXME: It'd be nice to isolate modules during init, too, so they 364/* FIXME: It'd be nice to isolate modules during init, too, so they
359 aren't used before they (may) fail. But presently too much code 365 aren't used before they (may) fail. But presently too much code
360 (IDE & SCSI) require entry into the module during init.*/ 366 (IDE & SCSI) require entry into the module during init.*/
@@ -363,10 +369,10 @@ static inline int module_is_live(struct module *mod)
363 return mod->state != MODULE_STATE_GOING; 369 return mod->state != MODULE_STATE_GOING;
364} 370}
365 371
366/* Is this address in a module? (second is with no locks, for oops) */
367struct module *module_text_address(unsigned long addr);
368struct module *__module_text_address(unsigned long addr); 372struct module *__module_text_address(unsigned long addr);
369int is_module_address(unsigned long addr); 373struct module *__module_address(unsigned long addr);
374bool is_module_address(unsigned long addr);
375bool is_module_text_address(unsigned long addr);
370 376
371static inline int within_module_core(unsigned long addr, struct module *mod) 377static inline int within_module_core(unsigned long addr, struct module *mod)
372{ 378{
@@ -380,6 +386,31 @@ static inline int within_module_init(unsigned long addr, struct module *mod)
380 addr < (unsigned long)mod->module_init + mod->init_size; 386 addr < (unsigned long)mod->module_init + mod->init_size;
381} 387}
382 388
389/* Search for module by name: must hold module_mutex. */
390struct module *find_module(const char *name);
391
392struct symsearch {
393 const struct kernel_symbol *start, *stop;
394 const unsigned long *crcs;
395 enum {
396 NOT_GPL_ONLY,
397 GPL_ONLY,
398 WILL_BE_GPL_ONLY,
399 } licence;
400 bool unused;
401};
402
403/* Search for an exported symbol by name. */
404const struct kernel_symbol *find_symbol(const char *name,
405 struct module **owner,
406 const unsigned long **crc,
407 bool gplok,
408 bool warn);
409
410/* Walk the exported symbol table */
411bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
412 unsigned int symnum, void *data), void *data);
413
383/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if 414/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
384 symnum out of range. */ 415 symnum out of range. */
385int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 416int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
@@ -388,6 +419,10 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
388/* Look for this name: can be of form module:name. */ 419/* Look for this name: can be of form module:name. */
389unsigned long module_kallsyms_lookup_name(const char *name); 420unsigned long module_kallsyms_lookup_name(const char *name);
390 421
422int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
423 struct module *, unsigned long),
424 void *data);
425
391extern void __module_put_and_exit(struct module *mod, long code) 426extern void __module_put_and_exit(struct module *mod, long code)
392 __attribute__((noreturn)); 427 __attribute__((noreturn));
393#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); 428#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
@@ -449,6 +484,7 @@ static inline void __module_get(struct module *module)
449#define symbol_put_addr(p) do { } while(0) 484#define symbol_put_addr(p) do { } while(0)
450 485
451#endif /* CONFIG_MODULE_UNLOAD */ 486#endif /* CONFIG_MODULE_UNLOAD */
487int use_module(struct module *a, struct module *b);
452 488
453/* This is a #define so the string doesn't get put in every .o file */ 489/* This is a #define so the string doesn't get put in every .o file */
454#define module_name(mod) \ 490#define module_name(mod) \
@@ -495,21 +531,24 @@ search_module_extables(unsigned long addr)
495 return NULL; 531 return NULL;
496} 532}
497 533
498/* Is this address in a module? */ 534static inline struct module *__module_address(unsigned long addr)
499static inline struct module *module_text_address(unsigned long addr)
500{ 535{
501 return NULL; 536 return NULL;
502} 537}
503 538
504/* Is this address in a module? (don't take a lock, we're oopsing) */
505static inline struct module *__module_text_address(unsigned long addr) 539static inline struct module *__module_text_address(unsigned long addr)
506{ 540{
507 return NULL; 541 return NULL;
508} 542}
509 543
510static inline int is_module_address(unsigned long addr) 544static inline bool is_module_address(unsigned long addr)
511{ 545{
512 return 0; 546 return false;
547}
548
549static inline bool is_module_text_address(unsigned long addr)
550{
551 return false;
513} 552}
514 553
515/* Get/put a kernel symbol (calls should be symmetric) */ 554/* Get/put a kernel symbol (calls should be symmetric) */
@@ -564,6 +603,14 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name)
564 return 0; 603 return 0;
565} 604}
566 605
606static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
607 struct module *,
608 unsigned long),
609 void *data)
610{
611 return 0;
612}
613
567static inline int register_module_notifier(struct notifier_block * nb) 614static inline int register_module_notifier(struct notifier_block * nb)
568{ 615{
569 /* no events will happen anyway, so this can always succeed */ 616 /* no events will happen anyway, so this can always succeed */