module.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. #ifndef _LINUX_MODULE_H
  2. #define _LINUX_MODULE_H
  3. /*
  4. * Dynamic loading of modules into the kernel.
  5. *
  6. * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
  7. * Rewritten again by Rusty Russell, 2002
  8. */
  9. #include <linux/list.h>
  10. #include <linux/stat.h>
  11. #include <linux/compiler.h>
  12. #include <linux/cache.h>
  13. #include <linux/kmod.h>
  14. #include <linux/elf.h>
  15. #include <linux/stringify.h>
  16. #include <linux/kobject.h>
  17. #include <linux/moduleparam.h>
  18. #include <linux/tracepoint.h>
  19. #include <linux/percpu.h>
  20. #include <asm/module.h>
  21. #include <trace/events/module.h>
  22. /* Not Yet Implemented */
  23. #define MODULE_SUPPORTED_DEVICE(name)
  24. /* Some toolchains use a `_' prefix for all user symbols. */
  25. #ifdef CONFIG_SYMBOL_PREFIX
  26. #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
  27. #else
  28. #define MODULE_SYMBOL_PREFIX ""
  29. #endif
  30. #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
  31. struct kernel_symbol
  32. {
  33. unsigned long value;
  34. const char *name;
  35. };
  36. struct modversion_info
  37. {
  38. unsigned long crc;
  39. char name[MODULE_NAME_LEN];
  40. };
  41. struct module;
  42. struct module_kobject {
  43. struct kobject kobj;
  44. struct module *mod;
  45. struct kobject *drivers_dir;
  46. struct module_param_attrs *mp;
  47. };
  48. struct module_attribute {
  49. struct attribute attr;
  50. ssize_t (*show)(struct module_attribute *, struct module_kobject *,
  51. char *);
  52. ssize_t (*store)(struct module_attribute *, struct module_kobject *,
  53. const char *, size_t count);
  54. void (*setup)(struct module *, const char *);
  55. int (*test)(struct module *);
  56. void (*free)(struct module *);
  57. };
  58. struct module_version_attribute {
  59. struct module_attribute mattr;
  60. const char *module_name;
  61. const char *version;
  62. } __attribute__ ((__aligned__(sizeof(void *))));
  63. extern ssize_t __modver_version_show(struct module_attribute *,
  64. struct module_kobject *, char *);
  65. extern struct module_attribute module_uevent;
  66. /* These are either module local, or the kernel's dummy ones. */
  67. extern int init_module(void);
  68. extern void cleanup_module(void);
  69. /* Archs provide a method of finding the correct exception table. */
  70. struct exception_table_entry;
  71. const struct exception_table_entry *
  72. search_extable(const struct exception_table_entry *first,
  73. const struct exception_table_entry *last,
  74. unsigned long value);
  75. void sort_extable(struct exception_table_entry *start,
  76. struct exception_table_entry *finish);
  77. void sort_main_extable(void);
  78. void trim_init_extable(struct module *m);
  79. #ifdef MODULE
  80. #define MODULE_GENERIC_TABLE(gtype,name) \
  81. extern const struct gtype##_id __mod_##gtype##_table \
  82. __attribute__ ((unused, alias(__stringify(name))))
  83. extern struct module __this_module;
  84. #define THIS_MODULE (&__this_module)
  85. #else /* !MODULE */
  86. #define MODULE_GENERIC_TABLE(gtype,name)
  87. #define THIS_MODULE ((struct module *)0)
  88. #endif
  89. /* Generic info of form tag = "info" */
  90. #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
  91. /* For userspace: you can also call me... */
  92. #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
  93. /*
  94. * The following license idents are currently accepted as indicating free
  95. * software modules
  96. *
  97. * "GPL" [GNU Public License v2 or later]
  98. * "GPL v2" [GNU Public License v2]
  99. * "GPL and additional rights" [GNU Public License v2 rights and more]
  100. * "Dual BSD/GPL" [GNU Public License v2
  101. * or BSD license choice]
  102. * "Dual MIT/GPL" [GNU Public License v2
  103. * or MIT license choice]
  104. * "Dual MPL/GPL" [GNU Public License v2
  105. * or Mozilla license choice]
  106. *
  107. * The following other idents are available
  108. *
  109. * "Proprietary" [Non free products]
  110. *
  111. * There are dual licensed components, but when running with Linux it is the
  112. * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
  113. * is a GPL combined work.
  114. *
  115. * This exists for several reasons
  116. * 1. So modinfo can show license info for users wanting to vet their setup
  117. * is free
  118. * 2. So the community can ignore bug reports including proprietary modules
  119. * 3. So vendors can do likewise based on their own policies
  120. */
  121. #define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
  122. /*
  123. * Author(s), use "Name <email>" or just "Name", for multiple
  124. * authors use multiple MODULE_AUTHOR() statements/lines.
  125. */
  126. #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
  127. /* What your module does. */
  128. #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
  129. /* One for each parameter, describing how to use it. Some files do
  130. multiple of these per line, so can't just use MODULE_INFO. */
  131. #define MODULE_PARM_DESC(_parm, desc) \
  132. __MODULE_INFO(parm, _parm, #_parm ":" desc)
  133. #define MODULE_DEVICE_TABLE(type,name) \
  134. MODULE_GENERIC_TABLE(type##_device,name)
  135. /* Version of form [<epoch>:]<version>[-<extra-version>].
  136. Or for CVS/RCS ID version, everything but the number is stripped.
  137. <epoch>: A (small) unsigned integer which allows you to start versions
  138. anew. If not mentioned, it's zero. eg. "2:1.0" is after
  139. "1:2.0".
  140. <version>: The <version> may contain only alphanumerics and the
  141. character `.'. Ordered by numeric sort for numeric parts,
  142. ascii sort for ascii parts (as per RPM or DEB algorithm).
  143. <extraversion>: Like <version>, but inserted for local
  144. customizations, eg "rh3" or "rusty1".
  145. Using this automatically adds a checksum of the .c files and the
  146. local headers in "srcversion".
  147. */
  148. #if defined(MODULE) || !defined(CONFIG_SYSFS)
  149. #define MODULE_VERSION(_version) MODULE_INFO(version, _version)
  150. #else
  151. #define MODULE_VERSION(_version) \
  152. static struct module_version_attribute ___modver_attr = { \
  153. .mattr = { \
  154. .attr = { \
  155. .name = "version", \
  156. .mode = S_IRUGO, \
  157. }, \
  158. .show = __modver_version_show, \
  159. }, \
  160. .module_name = KBUILD_MODNAME, \
  161. .version = _version, \
  162. }; \
  163. static const struct module_version_attribute \
  164. __used __attribute__ ((__section__ ("__modver"))) \
  165. * __moduleparam_const __modver_attr = &___modver_attr
  166. #endif
  167. /* Optional firmware file (or files) needed by the module
  168. * format is simply firmware file name. Multiple firmware
  169. * files require multiple MODULE_FIRMWARE() specifiers */
  170. #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
  171. /* Given an address, look for it in the exception tables */
  172. const struct exception_table_entry *search_exception_tables(unsigned long add);
  173. struct notifier_block;
  174. #ifdef CONFIG_MODULES
  175. extern int modules_disabled; /* for sysctl */
  176. /* Get/put a kernel symbol (calls must be symmetric) */
  177. void *__symbol_get(const char *symbol);
  178. void *__symbol_get_gpl(const char *symbol);
  179. #define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x)))
  180. /* modules using other modules: kdb wants to see this. */
  181. struct module_use {
  182. struct list_head source_list;
  183. struct list_head target_list;
  184. struct module *source, *target;
  185. };
  186. #ifndef __GENKSYMS__
  187. #ifdef CONFIG_MODVERSIONS
  188. /* Mark the CRC weak since genksyms apparently decides not to
  189. * generate a checksums for some symbols */
  190. #define __CRC_SYMBOL(sym, sec) \
  191. extern void *__crc_##sym __attribute__((weak)); \
  192. static const unsigned long __kcrctab_##sym \
  193. __used \
  194. __attribute__((section("___kcrctab" sec "+" #sym), unused)) \
  195. = (unsigned long) &__crc_##sym;
  196. #else
  197. #define __CRC_SYMBOL(sym, sec)
  198. #endif
  199. /* For every exported symbol, place a struct in the __ksymtab section */
  200. #define __EXPORT_SYMBOL(sym, sec) \
  201. extern typeof(sym) sym; \
  202. __CRC_SYMBOL(sym, sec) \
  203. static const char __kstrtab_##sym[] \
  204. __attribute__((section("__ksymtab_strings"), aligned(1))) \
  205. = MODULE_SYMBOL_PREFIX #sym; \
  206. static const struct kernel_symbol __ksymtab_##sym \
  207. __used \
  208. __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
  209. = { (unsigned long)&sym, __kstrtab_##sym }
  210. #define EXPORT_SYMBOL(sym) \
  211. __EXPORT_SYMBOL(sym, "")
  212. #define EXPORT_SYMBOL_GPL(sym) \
  213. __EXPORT_SYMBOL(sym, "_gpl")
  214. #define EXPORT_SYMBOL_GPL_FUTURE(sym) \
  215. __EXPORT_SYMBOL(sym, "_gpl_future")
  216. #ifdef CONFIG_UNUSED_SYMBOLS
  217. #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
  218. #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
  219. #else
  220. #define EXPORT_UNUSED_SYMBOL(sym)
  221. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  222. #endif
  223. #endif
  224. enum module_state
  225. {
  226. MODULE_STATE_LIVE,
  227. MODULE_STATE_COMING,
  228. MODULE_STATE_GOING,
  229. };
  230. struct module
  231. {
  232. enum module_state state;
  233. /* Member of list of modules */
  234. struct list_head list;
  235. /* Unique handle for this module */
  236. char name[MODULE_NAME_LEN];
  237. /* Sysfs stuff. */
  238. struct module_kobject mkobj;
  239. struct module_attribute *modinfo_attrs;
  240. const char *version;
  241. const char *srcversion;
  242. struct kobject *holders_dir;
  243. /* Exported symbols */
  244. const struct kernel_symbol *syms;
  245. const unsigned long *crcs;
  246. unsigned int num_syms;
  247. /* Kernel parameters. */
  248. struct kernel_param *kp;
  249. unsigned int num_kp;
  250. /* GPL-only exported symbols. */
  251. unsigned int num_gpl_syms;
  252. const struct kernel_symbol *gpl_syms;
  253. const unsigned long *gpl_crcs;
  254. #ifdef CONFIG_UNUSED_SYMBOLS
  255. /* unused exported symbols. */
  256. const struct kernel_symbol *unused_syms;
  257. const unsigned long *unused_crcs;
  258. unsigned int num_unused_syms;
  259. /* GPL-only, unused exported symbols. */
  260. unsigned int num_unused_gpl_syms;
  261. const struct kernel_symbol *unused_gpl_syms;
  262. const unsigned long *unused_gpl_crcs;
  263. #endif
  264. /* symbols that will be GPL-only in the near future. */
  265. const struct kernel_symbol *gpl_future_syms;
  266. const unsigned long *gpl_future_crcs;
  267. unsigned int num_gpl_future_syms;
  268. /* Exception table */
  269. unsigned int num_exentries;
  270. struct exception_table_entry *extable;
  271. /* Startup function. */
  272. int (*init)(void);
  273. /* If this is non-NULL, vfree after init() returns */
  274. void *module_init;
  275. /* Here is the actual code + data, vfree'd on unload. */
  276. void *module_core;
  277. /* Here are the sizes of the init and core sections */
  278. unsigned int init_size, core_size;
  279. /* The size of the executable code in each section. */
  280. unsigned int init_text_size, core_text_size;
  281. /* Size of RO sections of the module (text+rodata) */
  282. unsigned int init_ro_size, core_ro_size;
  283. /* Arch-specific module values */
  284. struct mod_arch_specific arch;
  285. unsigned int taints; /* same bits as kernel:tainted */
  286. #ifdef CONFIG_GENERIC_BUG
  287. /* Support for BUG */
  288. unsigned num_bugs;
  289. struct list_head bug_list;
  290. struct bug_entry *bug_table;
  291. #endif
  292. #ifdef CONFIG_KALLSYMS
  293. /*
  294. * We keep the symbol and string tables for kallsyms.
  295. * The core_* fields below are temporary, loader-only (they
  296. * could really be discarded after module init).
  297. */
  298. Elf_Sym *symtab, *core_symtab;
  299. unsigned int num_symtab, core_num_syms;
  300. char *strtab, *core_strtab;
  301. /* Section attributes */
  302. struct module_sect_attrs *sect_attrs;
  303. /* Notes attributes */
  304. struct module_notes_attrs *notes_attrs;
  305. #endif
  306. /* The command line arguments (may be mangled). People like
  307. keeping pointers to this stuff */
  308. char *args;
  309. #ifdef CONFIG_SMP
  310. /* Per-cpu data. */
  311. void __percpu *percpu;
  312. unsigned int percpu_size;
  313. #endif
  314. #ifdef CONFIG_TRACEPOINTS
  315. unsigned int num_tracepoints;
  316. struct tracepoint * const *tracepoints_ptrs;
  317. #endif
  318. #ifdef HAVE_JUMP_LABEL
  319. struct jump_entry *jump_entries;
  320. unsigned int num_jump_entries;
  321. #endif
  322. #ifdef CONFIG_TRACING
  323. unsigned int num_trace_bprintk_fmt;
  324. const char **trace_bprintk_fmt_start;
  325. #endif
  326. #ifdef CONFIG_EVENT_TRACING
  327. struct ftrace_event_call **trace_events;
  328. unsigned int num_trace_events;
  329. #endif
  330. #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  331. unsigned int num_ftrace_callsites;
  332. unsigned long *ftrace_callsites;
  333. #endif
  334. #ifdef CONFIG_MODULE_UNLOAD
  335. /* What modules depend on me? */
  336. struct list_head source_list;
  337. /* What modules do I depend on? */
  338. struct list_head target_list;
  339. /* Who is waiting for us to be unloaded */
  340. struct task_struct *waiter;
  341. /* Destruction function. */
  342. void (*exit)(void);
  343. struct module_ref {
  344. unsigned int incs;
  345. unsigned int decs;
  346. } __percpu *refptr;
  347. #endif
  348. #ifdef CONFIG_CONSTRUCTORS
  349. /* Constructor functions. */
  350. ctor_fn_t *ctors;
  351. unsigned int num_ctors;
  352. #endif
  353. };
  354. #ifndef MODULE_ARCH_INIT
  355. #define MODULE_ARCH_INIT {}
  356. #endif
  357. extern struct mutex module_mutex;
  358. /* 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
  360. (IDE & SCSI) require entry into the module during init.*/
  361. static inline int module_is_live(struct module *mod)
  362. {
  363. return mod->state != MODULE_STATE_GOING;
  364. }
  365. struct module *__module_text_address(unsigned long addr);
  366. struct module *__module_address(unsigned long addr);
  367. bool is_module_address(unsigned long addr);
  368. bool is_module_percpu_address(unsigned long addr);
  369. bool is_module_text_address(unsigned long addr);
  370. static inline int within_module_core(unsigned long addr, struct module *mod)
  371. {
  372. return (unsigned long)mod->module_core <= addr &&
  373. addr < (unsigned long)mod->module_core + mod->core_size;
  374. }
  375. static inline int within_module_init(unsigned long addr, struct module *mod)
  376. {
  377. return (unsigned long)mod->module_init <= addr &&
  378. addr < (unsigned long)mod->module_init + mod->init_size;
  379. }
  380. /* Search for module by name: must hold module_mutex. */
  381. struct module *find_module(const char *name);
  382. struct symsearch {
  383. const struct kernel_symbol *start, *stop;
  384. const unsigned long *crcs;
  385. enum {
  386. NOT_GPL_ONLY,
  387. GPL_ONLY,
  388. WILL_BE_GPL_ONLY,
  389. } licence;
  390. bool unused;
  391. };
  392. /* Search for an exported symbol by name. */
  393. const struct kernel_symbol *find_symbol(const char *name,
  394. struct module **owner,
  395. const unsigned long **crc,
  396. bool gplok,
  397. bool warn);
  398. /* Walk the exported symbol table */
  399. bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
  400. struct module *owner,
  401. void *data), void *data);
  402. /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
  403. symnum out of range. */
  404. int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
  405. char *name, char *module_name, int *exported);
  406. /* Look for this name: can be of form module:name. */
  407. unsigned long module_kallsyms_lookup_name(const char *name);
  408. int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  409. struct module *, unsigned long),
  410. void *data);
  411. extern void __module_put_and_exit(struct module *mod, long code)
  412. __attribute__((noreturn));
  413. #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
  414. #ifdef CONFIG_MODULE_UNLOAD
  415. unsigned int module_refcount(struct module *mod);
  416. void __symbol_put(const char *symbol);
  417. #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
  418. void symbol_put_addr(void *addr);
  419. /* Sometimes we know we already have a refcount, and it's easier not
  420. to handle the error case (which only happens with rmmod --wait). */
  421. static inline void __module_get(struct module *module)
  422. {
  423. if (module) {
  424. preempt_disable();
  425. __this_cpu_inc(module->refptr->incs);
  426. trace_module_get(module, _THIS_IP_);
  427. preempt_enable();
  428. }
  429. }
  430. static inline int try_module_get(struct module *module)
  431. {
  432. int ret = 1;
  433. if (module) {
  434. preempt_disable();
  435. if (likely(module_is_live(module))) {
  436. __this_cpu_inc(module->refptr->incs);
  437. trace_module_get(module, _THIS_IP_);
  438. } else
  439. ret = 0;
  440. preempt_enable();
  441. }
  442. return ret;
  443. }
  444. extern void module_put(struct module *module);
  445. #else /*!CONFIG_MODULE_UNLOAD*/
  446. static inline int try_module_get(struct module *module)
  447. {
  448. return !module || module_is_live(module);
  449. }
  450. static inline void module_put(struct module *module)
  451. {
  452. }
  453. static inline void __module_get(struct module *module)
  454. {
  455. }
  456. #define symbol_put(x) do { } while(0)
  457. #define symbol_put_addr(p) do { } while(0)
  458. #endif /* CONFIG_MODULE_UNLOAD */
  459. int ref_module(struct module *a, struct module *b);
  460. /* This is a #define so the string doesn't get put in every .o file */
  461. #define module_name(mod) \
  462. ({ \
  463. struct module *__mod = (mod); \
  464. __mod ? __mod->name : "kernel"; \
  465. })
  466. /* For kallsyms to ask for address resolution. namebuf should be at
  467. * least KSYM_NAME_LEN long: a pointer to namebuf is returned if
  468. * found, otherwise NULL. */
  469. const char *module_address_lookup(unsigned long addr,
  470. unsigned long *symbolsize,
  471. unsigned long *offset,
  472. char **modname,
  473. char *namebuf);
  474. int lookup_module_symbol_name(unsigned long addr, char *symname);
  475. int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
  476. /* For extable.c to search modules' exception tables. */
  477. const struct exception_table_entry *search_module_extables(unsigned long addr);
  478. int register_module_notifier(struct notifier_block * nb);
  479. int unregister_module_notifier(struct notifier_block * nb);
  480. extern void print_modules(void);
  481. #else /* !CONFIG_MODULES... */
  482. #define EXPORT_SYMBOL(sym)
  483. #define EXPORT_SYMBOL_GPL(sym)
  484. #define EXPORT_SYMBOL_GPL_FUTURE(sym)
  485. #define EXPORT_UNUSED_SYMBOL(sym)
  486. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  487. /* Given an address, look for it in the exception tables. */
  488. static inline const struct exception_table_entry *
  489. search_module_extables(unsigned long addr)
  490. {
  491. return NULL;
  492. }
  493. static inline struct module *__module_address(unsigned long addr)
  494. {
  495. return NULL;
  496. }
  497. static inline struct module *__module_text_address(unsigned long addr)
  498. {
  499. return NULL;
  500. }
  501. static inline bool is_module_address(unsigned long addr)
  502. {
  503. return false;
  504. }
  505. static inline bool is_module_percpu_address(unsigned long addr)
  506. {
  507. return false;
  508. }
  509. static inline bool is_module_text_address(unsigned long addr)
  510. {
  511. return false;
  512. }
  513. /* Get/put a kernel symbol (calls should be symmetric) */
  514. #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
  515. #define symbol_put(x) do { } while(0)
  516. #define symbol_put_addr(x) do { } while(0)
  517. static inline void __module_get(struct module *module)
  518. {
  519. }
  520. static inline int try_module_get(struct module *module)
  521. {
  522. return 1;
  523. }
  524. static inline void module_put(struct module *module)
  525. {
  526. }
  527. #define module_name(mod) "kernel"
  528. /* For kallsyms to ask for address resolution. NULL means not found. */
  529. static inline const char *module_address_lookup(unsigned long addr,
  530. unsigned long *symbolsize,
  531. unsigned long *offset,
  532. char **modname,
  533. char *namebuf)
  534. {
  535. return NULL;
  536. }
  537. static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
  538. {
  539. return -ERANGE;
  540. }
  541. static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
  542. {
  543. return -ERANGE;
  544. }
  545. static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
  546. char *type, char *name,
  547. char *module_name, int *exported)
  548. {
  549. return -ERANGE;
  550. }
  551. static inline unsigned long module_kallsyms_lookup_name(const char *name)
  552. {
  553. return 0;
  554. }
  555. static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  556. struct module *,
  557. unsigned long),
  558. void *data)
  559. {
  560. return 0;
  561. }
  562. static inline int register_module_notifier(struct notifier_block * nb)
  563. {
  564. /* no events will happen anyway, so this can always succeed */
  565. return 0;
  566. }
  567. static inline int unregister_module_notifier(struct notifier_block * nb)
  568. {
  569. return 0;
  570. }
  571. #define module_put_and_exit(code) do_exit(code)
  572. static inline void print_modules(void)
  573. {
  574. }
  575. #endif /* CONFIG_MODULES */
  576. #ifdef CONFIG_SYSFS
  577. extern struct kset *module_kset;
  578. extern struct kobj_type module_ktype;
  579. extern int module_sysfs_initialized;
  580. #endif /* CONFIG_SYSFS */
  581. #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
  582. /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
  583. #define __MODULE_STRING(x) __stringify(x)
  584. #ifdef CONFIG_DEBUG_SET_MODULE_RONX
  585. extern void set_all_modules_text_rw(void);
  586. extern void set_all_modules_text_ro(void);
  587. #else
  588. static inline void set_all_modules_text_rw(void) { }
  589. static inline void set_all_modules_text_ro(void) { }
  590. #endif
  591. #ifdef CONFIG_GENERIC_BUG
  592. void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
  593. struct module *);
  594. void module_bug_cleanup(struct module *);
  595. #else /* !CONFIG_GENERIC_BUG */
  596. static inline void module_bug_finalize(const Elf_Ehdr *hdr,
  597. const Elf_Shdr *sechdrs,
  598. struct module *mod)
  599. {
  600. }
  601. static inline void module_bug_cleanup(struct module *mod) {}
  602. #endif /* CONFIG_GENERIC_BUG */
  603. #endif /* _LINUX_MODULE_H */