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 145a75528cc1..d246da0b0f8c 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;
@@ -350,6 +354,8 @@ struct module
350#define MODULE_ARCH_INIT {} 354#define MODULE_ARCH_INIT {}
351#endif 355#endif
352 356
357extern struct mutex module_mutex;
358
353/* FIXME: It'd be nice to isolate modules during init, too, so they 359/* FIXME: It'd be nice to isolate modules during init, too, so they
354 aren't used before they (may) fail. But presently too much code 360 aren't used before they (may) fail. But presently too much code
355 (IDE & SCSI) require entry into the module during init.*/ 361 (IDE & SCSI) require entry into the module during init.*/
@@ -358,10 +364,10 @@ static inline int module_is_live(struct module *mod)
358 return mod->state != MODULE_STATE_GOING; 364 return mod->state != MODULE_STATE_GOING;
359} 365}
360 366
361/* Is this address in a module? (second is with no locks, for oops) */
362struct module *module_text_address(unsigned long addr);
363struct module *__module_text_address(unsigned long addr); 367struct module *__module_text_address(unsigned long addr);
364int is_module_address(unsigned long addr); 368struct module *__module_address(unsigned long addr);
369bool is_module_address(unsigned long addr);
370bool is_module_text_address(unsigned long addr);
365 371
366static inline int within_module_core(unsigned long addr, struct module *mod) 372static inline int within_module_core(unsigned long addr, struct module *mod)
367{ 373{
@@ -375,6 +381,31 @@ static inline int within_module_init(unsigned long addr, struct module *mod)
375 addr < (unsigned long)mod->module_init + mod->init_size; 381 addr < (unsigned long)mod->module_init + mod->init_size;
376} 382}
377 383
384/* Search for module by name: must hold module_mutex. */
385struct module *find_module(const char *name);
386
387struct symsearch {
388 const struct kernel_symbol *start, *stop;
389 const unsigned long *crcs;
390 enum {
391 NOT_GPL_ONLY,
392 GPL_ONLY,
393 WILL_BE_GPL_ONLY,
394 } licence;
395 bool unused;
396};
397
398/* Search for an exported symbol by name. */
399const struct kernel_symbol *find_symbol(const char *name,
400 struct module **owner,
401 const unsigned long **crc,
402 bool gplok,
403 bool warn);
404
405/* Walk the exported symbol table */
406bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
407 unsigned int symnum, void *data), void *data);
408
378/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if 409/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
379 symnum out of range. */ 410 symnum out of range. */
380int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, 411int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
@@ -383,6 +414,10 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
383/* Look for this name: can be of form module:name. */ 414/* Look for this name: can be of form module:name. */
384unsigned long module_kallsyms_lookup_name(const char *name); 415unsigned long module_kallsyms_lookup_name(const char *name);
385 416
417int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
418 struct module *, unsigned long),
419 void *data);
420
386extern void __module_put_and_exit(struct module *mod, long code) 421extern void __module_put_and_exit(struct module *mod, long code)
387 __attribute__((noreturn)); 422 __attribute__((noreturn));
388#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); 423#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
@@ -444,6 +479,7 @@ static inline void __module_get(struct module *module)
444#define symbol_put_addr(p) do { } while(0) 479#define symbol_put_addr(p) do { } while(0)
445 480
446#endif /* CONFIG_MODULE_UNLOAD */ 481#endif /* CONFIG_MODULE_UNLOAD */
482int use_module(struct module *a, struct module *b);
447 483
448/* This is a #define so the string doesn't get put in every .o file */ 484/* This is a #define so the string doesn't get put in every .o file */
449#define module_name(mod) \ 485#define module_name(mod) \
@@ -490,21 +526,24 @@ search_module_extables(unsigned long addr)
490 return NULL; 526 return NULL;
491} 527}
492 528
493/* Is this address in a module? */ 529static inline struct module *__module_address(unsigned long addr)
494static inline struct module *module_text_address(unsigned long addr)
495{ 530{
496 return NULL; 531 return NULL;
497} 532}
498 533
499/* Is this address in a module? (don't take a lock, we're oopsing) */
500static inline struct module *__module_text_address(unsigned long addr) 534static inline struct module *__module_text_address(unsigned long addr)
501{ 535{
502 return NULL; 536 return NULL;
503} 537}
504 538
505static inline int is_module_address(unsigned long addr) 539static inline bool is_module_address(unsigned long addr)
506{ 540{
507 return 0; 541 return false;
542}
543
544static inline bool is_module_text_address(unsigned long addr)
545{
546 return false;
508} 547}
509 548
510/* Get/put a kernel symbol (calls should be symmetric) */ 549/* Get/put a kernel symbol (calls should be symmetric) */
@@ -559,6 +598,14 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name)
559 return 0; 598 return 0;
560} 599}
561 600
601static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
602 struct module *,
603 unsigned long),
604 void *data)
605{
606 return 0;
607}
608
562static inline int register_module_notifier(struct notifier_block * nb) 609static inline int register_module_notifier(struct notifier_block * nb)
563{ 610{
564 /* no events will happen anyway, so this can always succeed */ 611 /* no events will happen anyway, so this can always succeed */