module.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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. /* These are either module local, or the kernel's dummy ones. */
  66. extern int init_module(void);
  67. extern void cleanup_module(void);
  68. /* Archs provide a method of finding the correct exception table. */
  69. struct exception_table_entry;
  70. const struct exception_table_entry *
  71. search_extable(const struct exception_table_entry *first,
  72. const struct exception_table_entry *last,
  73. unsigned long value);
  74. void sort_extable(struct exception_table_entry *start,
  75. struct exception_table_entry *finish);
  76. void sort_main_extable(void);
  77. void trim_init_extable(struct module *m);
  78. #ifdef MODULE
  79. #define MODULE_GENERIC_TABLE(gtype,name) \
  80. extern const struct gtype##_id __mod_##gtype##_table \
  81. __attribute__ ((unused, alias(__stringify(name))))
  82. extern struct module __this_module;
  83. #define THIS_MODULE (&__this_module)
  84. #else /* !MODULE */
  85. #define MODULE_GENERIC_TABLE(gtype,name)
  86. #define THIS_MODULE ((struct module *)0)
  87. #endif
  88. /* Generic info of form tag = "info" */
  89. #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
  90. /* For userspace: you can also call me... */
  91. #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
  92. /*
  93. * The following license idents are currently accepted as indicating free
  94. * software modules
  95. *
  96. * "GPL" [GNU Public License v2 or later]
  97. * "GPL v2" [GNU Public License v2]
  98. * "GPL and additional rights" [GNU Public License v2 rights and more]
  99. * "Dual BSD/GPL" [GNU Public License v2
  100. * or BSD license choice]
  101. * "Dual MIT/GPL" [GNU Public License v2
  102. * or MIT license choice]
  103. * "Dual MPL/GPL" [GNU Public License v2
  104. * or Mozilla license choice]
  105. *
  106. * The following other idents are available
  107. *
  108. * "Proprietary" [Non free products]
  109. *
  110. * There are dual licensed components, but when running with Linux it is the
  111. * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
  112. * is a GPL combined work.
  113. *
  114. * This exists for several reasons
  115. * 1. So modinfo can show license info for users wanting to vet their setup
  116. * is free
  117. * 2. So the community can ignore bug reports including proprietary modules
  118. * 3. So vendors can do likewise based on their own policies
  119. */
  120. #define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
  121. /*
  122. * Author(s), use "Name <email>" or just "Name", for multiple
  123. * authors use multiple MODULE_AUTHOR() statements/lines.
  124. */
  125. #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
  126. /* What your module does. */
  127. #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
  128. /* One for each parameter, describing how to use it. Some files do
  129. multiple of these per line, so can't just use MODULE_INFO. */
  130. #define MODULE_PARM_DESC(_parm, desc) \
  131. __MODULE_INFO(parm, _parm, #_parm ":" desc)
  132. #define MODULE_DEVICE_TABLE(type,name) \
  133. MODULE_GENERIC_TABLE(type##_device,name)
  134. /* Version of form [<epoch>:]<version>[-<extra-version>].
  135. Or for CVS/RCS ID version, everything but the number is stripped.
  136. <epoch>: A (small) unsigned integer which allows you to start versions
  137. anew. If not mentioned, it's zero. eg. "2:1.0" is after
  138. "1:2.0".
  139. <version>: The <version> may contain only alphanumerics and the
  140. character `.'. Ordered by numeric sort for numeric parts,
  141. ascii sort for ascii parts (as per RPM or DEB algorithm).
  142. <extraversion>: Like <version>, but inserted for local
  143. customizations, eg "rh3" or "rusty1".
  144. Using this automatically adds a checksum of the .c files and the
  145. local headers in "srcversion".
  146. */
  147. #if defined(MODULE) || !defined(CONFIG_SYSFS)
  148. #define MODULE_VERSION(_version) MODULE_INFO(version, _version)
  149. #else
  150. #define MODULE_VERSION(_version) \
  151. static struct module_version_attribute ___modver_attr = { \
  152. .mattr = { \
  153. .attr = { \
  154. .name = "version", \
  155. .mode = S_IRUGO, \
  156. }, \
  157. .show = __modver_version_show, \
  158. }, \
  159. .module_name = KBUILD_MODNAME, \
  160. .version = _version, \
  161. }; \
  162. static const struct module_version_attribute \
  163. __used __attribute__ ((__section__ ("__modver"))) \
  164. * __moduleparam_const __modver_attr = &___modver_attr
  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 "+" #sym), 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 "+" #sym), 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. /* The command line arguments (may be mangled). People like
  306. keeping pointers to this stuff */
  307. char *args;
  308. #ifdef CONFIG_SMP
  309. /* Per-cpu data. */
  310. void __percpu *percpu;
  311. unsigned int percpu_size;
  312. #endif
  313. #ifdef CONFIG_TRACEPOINTS
  314. unsigned int num_tracepoints;
  315. struct tracepoint * const *tracepoints_ptrs;
  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. unsigned int num_trace_bprintk_fmt;
  323. const char **trace_bprintk_fmt_start;
  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 int num_ftrace_callsites;
  331. unsigned long *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_section(bool (*fn)(const struct symsearch *arr,
  399. struct module *owner,
  400. void *data), void *data);
  401. /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
  402. symnum out of range. */
  403. int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
  404. char *name, char *module_name, int *exported);
  405. /* Look for this name: can be of form module:name. */
  406. unsigned long module_kallsyms_lookup_name(const char *name);
  407. int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  408. struct module *, unsigned long),
  409. void *data);
  410. extern void __module_put_and_exit(struct module *mod, long code)
  411. __attribute__((noreturn));
  412. #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
  413. #ifdef CONFIG_MODULE_UNLOAD
  414. unsigned int module_refcount(struct module *mod);
  415. void __symbol_put(const char *symbol);
  416. #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
  417. void symbol_put_addr(void *addr);
  418. /* Sometimes we know we already have a refcount, and it's easier not
  419. to handle the error case (which only happens with rmmod --wait). */
  420. static inline void __module_get(struct module *module)
  421. {
  422. if (module) {
  423. preempt_disable();
  424. __this_cpu_inc(module->refptr->incs);
  425. trace_module_get(module, _THIS_IP_);
  426. preempt_enable();
  427. }
  428. }
  429. static inline int try_module_get(struct module *module)
  430. {
  431. int ret = 1;
  432. if (module) {
  433. preempt_disable();
  434. if (likely(module_is_live(module))) {
  435. __this_cpu_inc(module->refptr->incs);
  436. trace_module_get(module, _THIS_IP_);
  437. } else
  438. ret = 0;
  439. preempt_enable();
  440. }
  441. return ret;
  442. }
  443. extern void module_put(struct module *module);
  444. #else /*!CONFIG_MODULE_UNLOAD*/
  445. static inline int try_module_get(struct module *module)
  446. {
  447. return !module || module_is_live(module);
  448. }
  449. static inline void module_put(struct module *module)
  450. {
  451. }
  452. static inline void __module_get(struct module *module)
  453. {
  454. }
  455. #define symbol_put(x) do { } while(0)
  456. #define symbol_put_addr(p) do { } while(0)
  457. #endif /* CONFIG_MODULE_UNLOAD */
  458. int ref_module(struct module *a, struct module *b);
  459. /* This is a #define so the string doesn't get put in every .o file */
  460. #define module_name(mod) \
  461. ({ \
  462. struct module *__mod = (mod); \
  463. __mod ? __mod->name : "kernel"; \
  464. })
  465. /* For kallsyms to ask for address resolution. namebuf should be at
  466. * least KSYM_NAME_LEN long: a pointer to namebuf is returned if
  467. * found, otherwise NULL. */
  468. const char *module_address_lookup(unsigned long addr,
  469. unsigned long *symbolsize,
  470. unsigned long *offset,
  471. char **modname,
  472. char *namebuf);
  473. int lookup_module_symbol_name(unsigned long addr, char *symname);
  474. int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
  475. /* For extable.c to search modules' exception tables. */
  476. const struct exception_table_entry *search_module_extables(unsigned long addr);
  477. int register_module_notifier(struct notifier_block * nb);
  478. int unregister_module_notifier(struct notifier_block * nb);
  479. extern void print_modules(void);
  480. extern void module_update_tracepoints(void);
  481. extern int module_get_iter_tracepoints(struct tracepoint_iter *iter);
  482. #else /* !CONFIG_MODULES... */
  483. #define EXPORT_SYMBOL(sym)
  484. #define EXPORT_SYMBOL_GPL(sym)
  485. #define EXPORT_SYMBOL_GPL_FUTURE(sym)
  486. #define EXPORT_UNUSED_SYMBOL(sym)
  487. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  488. /* Given an address, look for it in the exception tables. */
  489. static inline const struct exception_table_entry *
  490. search_module_extables(unsigned long addr)
  491. {
  492. return NULL;
  493. }
  494. static inline struct module *__module_address(unsigned long addr)
  495. {
  496. return NULL;
  497. }
  498. static inline struct module *__module_text_address(unsigned long addr)
  499. {
  500. return NULL;
  501. }
  502. static inline bool is_module_address(unsigned long addr)
  503. {
  504. return false;
  505. }
  506. static inline bool is_module_percpu_address(unsigned long addr)
  507. {
  508. return false;
  509. }
  510. static inline bool is_module_text_address(unsigned long addr)
  511. {
  512. return false;
  513. }
  514. /* Get/put a kernel symbol (calls should be symmetric) */
  515. #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
  516. #define symbol_put(x) do { } while(0)
  517. #define symbol_put_addr(x) do { } while(0)
  518. static inline void __module_get(struct module *module)
  519. {
  520. }
  521. static inline int try_module_get(struct module *module)
  522. {
  523. return 1;
  524. }
  525. static inline void module_put(struct module *module)
  526. {
  527. }
  528. #define module_name(mod) "kernel"
  529. /* For kallsyms to ask for address resolution. NULL means not found. */
  530. static inline const char *module_address_lookup(unsigned long addr,
  531. unsigned long *symbolsize,
  532. unsigned long *offset,
  533. char **modname,
  534. char *namebuf)
  535. {
  536. return NULL;
  537. }
  538. static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
  539. {
  540. return -ERANGE;
  541. }
  542. static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
  543. {
  544. return -ERANGE;
  545. }
  546. static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
  547. char *type, char *name,
  548. char *module_name, int *exported)
  549. {
  550. return -ERANGE;
  551. }
  552. static inline unsigned long module_kallsyms_lookup_name(const char *name)
  553. {
  554. return 0;
  555. }
  556. static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  557. struct module *,
  558. unsigned long),
  559. void *data)
  560. {
  561. return 0;
  562. }
  563. static inline int register_module_notifier(struct notifier_block * nb)
  564. {
  565. /* no events will happen anyway, so this can always succeed */
  566. return 0;
  567. }
  568. static inline int unregister_module_notifier(struct notifier_block * nb)
  569. {
  570. return 0;
  571. }
  572. #define module_put_and_exit(code) do_exit(code)
  573. static inline void print_modules(void)
  574. {
  575. }
  576. static inline void module_update_tracepoints(void)
  577. {
  578. }
  579. static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter)
  580. {
  581. return 0;
  582. }
  583. #endif /* CONFIG_MODULES */
  584. #ifdef CONFIG_SYSFS
  585. extern struct kset *module_kset;
  586. extern struct kobj_type module_ktype;
  587. extern int module_sysfs_initialized;
  588. #endif /* CONFIG_SYSFS */
  589. #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
  590. /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
  591. #define __MODULE_STRING(x) __stringify(x)
  592. #ifdef CONFIG_DEBUG_SET_MODULE_RONX
  593. extern void set_all_modules_text_rw(void);
  594. extern void set_all_modules_text_ro(void);
  595. #else
  596. static inline void set_all_modules_text_rw(void) { }
  597. static inline void set_all_modules_text_ro(void) { }
  598. #endif
  599. #ifdef CONFIG_GENERIC_BUG
  600. void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
  601. struct module *);
  602. void module_bug_cleanup(struct module *);
  603. #else /* !CONFIG_GENERIC_BUG */
  604. static inline void module_bug_finalize(const Elf_Ehdr *hdr,
  605. const Elf_Shdr *sechdrs,
  606. struct module *mod)
  607. {
  608. }
  609. static inline void module_bug_cleanup(struct module *mod) {}
  610. #endif /* CONFIG_GENERIC_BUG */
  611. #endif /* _LINUX_MODULE_H */