module.h 20 KB

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