kallsyms.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * kallsyms.c: in-kernel printing of symbolic oopses and stack traces.
  3. *
  4. * Rewritten and vastly simplified by Rusty Russell for in-kernel
  5. * module loader:
  6. * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
  7. *
  8. * ChangeLog:
  9. *
  10. * (25/Aug/2004) Paulo Marques <pmarques@grupopie.com>
  11. * Changed the compression method from stem compression to "table lookup"
  12. * compression (see scripts/kallsyms.c for a more complete description)
  13. */
  14. #include <linux/kallsyms.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <linux/seq_file.h>
  18. #include <linux/fs.h>
  19. #include <linux/kdb.h>
  20. #include <linux/err.h>
  21. #include <linux/proc_fs.h>
  22. #include <linux/sched.h> /* for cond_resched */
  23. #include <linux/mm.h>
  24. #include <linux/ctype.h>
  25. #include <linux/slab.h>
  26. #include <linux/filter.h>
  27. #include <linux/compiler.h>
  28. #include <asm/sections.h>
  29. /*
  30. * These will be re-linked against their real values
  31. * during the second link stage.
  32. */
  33. extern const unsigned long kallsyms_addresses[] __weak;
  34. extern const int kallsyms_offsets[] __weak;
  35. extern const u8 kallsyms_names[] __weak;
  36. /*
  37. * Tell the compiler that the count isn't in the small data section if the arch
  38. * has one (eg: FRV).
  39. */
  40. extern const unsigned long kallsyms_num_syms
  41. __attribute__((weak, section(".rodata")));
  42. extern const unsigned long kallsyms_relative_base
  43. __attribute__((weak, section(".rodata")));
  44. extern const u8 kallsyms_token_table[] __weak;
  45. extern const u16 kallsyms_token_index[] __weak;
  46. extern const unsigned long kallsyms_markers[] __weak;
  47. static inline int is_kernel_inittext(unsigned long addr)
  48. {
  49. if (addr >= (unsigned long)_sinittext
  50. && addr <= (unsigned long)_einittext)
  51. return 1;
  52. return 0;
  53. }
  54. static inline int is_kernel_text(unsigned long addr)
  55. {
  56. if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
  57. arch_is_kernel_text(addr))
  58. return 1;
  59. return in_gate_area_no_mm(addr);
  60. }
  61. static inline int is_kernel(unsigned long addr)
  62. {
  63. if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
  64. return 1;
  65. return in_gate_area_no_mm(addr);
  66. }
  67. static int is_ksym_addr(unsigned long addr)
  68. {
  69. if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
  70. return is_kernel(addr);
  71. return is_kernel_text(addr) || is_kernel_inittext(addr);
  72. }
  73. /*
  74. * Expand a compressed symbol data into the resulting uncompressed string,
  75. * if uncompressed string is too long (>= maxlen), it will be truncated,
  76. * given the offset to where the symbol is in the compressed stream.
  77. */
  78. static unsigned int kallsyms_expand_symbol(unsigned int off,
  79. char *result, size_t maxlen)
  80. {
  81. int len, skipped_first = 0;
  82. const u8 *tptr, *data;
  83. /* Get the compressed symbol length from the first symbol byte. */
  84. data = &kallsyms_names[off];
  85. len = *data;
  86. data++;
  87. /*
  88. * Update the offset to return the offset for the next symbol on
  89. * the compressed stream.
  90. */
  91. off += len + 1;
  92. /*
  93. * For every byte on the compressed symbol data, copy the table
  94. * entry for that byte.
  95. */
  96. while (len) {
  97. tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
  98. data++;
  99. len--;
  100. while (*tptr) {
  101. if (skipped_first) {
  102. if (maxlen <= 1)
  103. goto tail;
  104. *result = *tptr;
  105. result++;
  106. maxlen--;
  107. } else
  108. skipped_first = 1;
  109. tptr++;
  110. }
  111. }
  112. tail:
  113. if (maxlen)
  114. *result = '\0';
  115. /* Return to offset to the next symbol. */
  116. return off;
  117. }
  118. /*
  119. * Get symbol type information. This is encoded as a single char at the
  120. * beginning of the symbol name.
  121. */
  122. static char kallsyms_get_symbol_type(unsigned int off)
  123. {
  124. /*
  125. * Get just the first code, look it up in the token table,
  126. * and return the first char from this token.
  127. */
  128. return kallsyms_token_table[kallsyms_token_index[kallsyms_names[off + 1]]];
  129. }
  130. /*
  131. * Find the offset on the compressed stream given and index in the
  132. * kallsyms array.
  133. */
  134. static unsigned int get_symbol_offset(unsigned long pos)
  135. {
  136. const u8 *name;
  137. int i;
  138. /*
  139. * Use the closest marker we have. We have markers every 256 positions,
  140. * so that should be close enough.
  141. */
  142. name = &kallsyms_names[kallsyms_markers[pos >> 8]];
  143. /*
  144. * Sequentially scan all the symbols up to the point we're searching
  145. * for. Every symbol is stored in a [<len>][<len> bytes of data] format,
  146. * so we just need to add the len to the current pointer for every
  147. * symbol we wish to skip.
  148. */
  149. for (i = 0; i < (pos & 0xFF); i++)
  150. name = name + (*name) + 1;
  151. return name - kallsyms_names;
  152. }
  153. static unsigned long kallsyms_sym_address(int idx)
  154. {
  155. if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE))
  156. return kallsyms_addresses[idx];
  157. /* values are unsigned offsets if --absolute-percpu is not in effect */
  158. if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU))
  159. return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
  160. /* ...otherwise, positive offsets are absolute values */
  161. if (kallsyms_offsets[idx] >= 0)
  162. return kallsyms_offsets[idx];
  163. /* ...and negative offsets are relative to kallsyms_relative_base - 1 */
  164. return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
  165. }
  166. /* Lookup the address for this symbol. Returns 0 if not found. */
  167. unsigned long kallsyms_lookup_name(const char *name)
  168. {
  169. char namebuf[KSYM_NAME_LEN];
  170. unsigned long i;
  171. unsigned int off;
  172. for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
  173. off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));
  174. if (strcmp(namebuf, name) == 0)
  175. return kallsyms_sym_address(i);
  176. }
  177. return module_kallsyms_lookup_name(name);
  178. }
  179. EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
  180. int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
  181. unsigned long),
  182. void *data)
  183. {
  184. char namebuf[KSYM_NAME_LEN];
  185. unsigned long i;
  186. unsigned int off;
  187. int ret;
  188. for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
  189. off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));
  190. ret = fn(data, namebuf, NULL, kallsyms_sym_address(i));
  191. if (ret != 0)
  192. return ret;
  193. }
  194. return module_kallsyms_on_each_symbol(fn, data);
  195. }
  196. EXPORT_SYMBOL_GPL(kallsyms_on_each_symbol);
  197. static unsigned long get_symbol_pos(unsigned long addr,
  198. unsigned long *symbolsize,
  199. unsigned long *offset)
  200. {
  201. unsigned long symbol_start = 0, symbol_end = 0;
  202. unsigned long i, low, high, mid;
  203. /* This kernel should never had been booted. */
  204. if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE))
  205. BUG_ON(!kallsyms_addresses);
  206. else
  207. BUG_ON(!kallsyms_offsets);
  208. /* Do a binary search on the sorted kallsyms_addresses array. */
  209. low = 0;
  210. high = kallsyms_num_syms;
  211. while (high - low > 1) {
  212. mid = low + (high - low) / 2;
  213. if (kallsyms_sym_address(mid) <= addr)
  214. low = mid;
  215. else
  216. high = mid;
  217. }
  218. /*
  219. * Search for the first aliased symbol. Aliased
  220. * symbols are symbols with the same address.
  221. */
  222. while (low && kallsyms_sym_address(low-1) == kallsyms_sym_address(low))
  223. --low;
  224. symbol_start = kallsyms_sym_address(low);
  225. /* Search for next non-aliased symbol. */
  226. for (i = low + 1; i < kallsyms_num_syms; i++) {
  227. if (kallsyms_sym_address(i) > symbol_start) {
  228. symbol_end = kallsyms_sym_address(i);
  229. break;
  230. }
  231. }
  232. /* If we found no next symbol, we use the end of the section. */
  233. if (!symbol_end) {
  234. if (is_kernel_inittext(addr))
  235. symbol_end = (unsigned long)_einittext;
  236. else if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
  237. symbol_end = (unsigned long)_end;
  238. else
  239. symbol_end = (unsigned long)_etext;
  240. }
  241. if (symbolsize)
  242. *symbolsize = symbol_end - symbol_start;
  243. if (offset)
  244. *offset = addr - symbol_start;
  245. return low;
  246. }
  247. /*
  248. * Lookup an address but don't bother to find any names.
  249. */
  250. int kallsyms_lookup_size_offset(unsigned long addr, unsigned long *symbolsize,
  251. unsigned long *offset)
  252. {
  253. char namebuf[KSYM_NAME_LEN];
  254. if (is_ksym_addr(addr)) {
  255. get_symbol_pos(addr, symbolsize, offset);
  256. return 1;
  257. }
  258. return !!module_address_lookup(addr, symbolsize, offset, NULL, namebuf) ||
  259. !!__bpf_address_lookup(addr, symbolsize, offset, namebuf);
  260. }
  261. #ifdef CONFIG_CFI_CLANG
  262. /*
  263. * LLVM appends .cfi to function names when CONFIG_CFI_CLANG is enabled,
  264. * which causes confusion and potentially breaks user space tools, so we
  265. * will strip the postfix from expanded symbol names.
  266. */
  267. static inline void cleanup_symbol_name(char *s)
  268. {
  269. char *res;
  270. #ifdef CONFIG_THINLTO
  271. /* Filter out hashes from static functions */
  272. res = strrchr(s, '$');
  273. if (res)
  274. *res = '\0';
  275. #endif
  276. res = strrchr(s, '.');
  277. if (res && !strcmp(res, ".cfi"))
  278. *res = '\0';
  279. }
  280. #else
  281. static inline void cleanup_symbol_name(char *s) {}
  282. #endif
  283. /*
  284. * Lookup an address
  285. * - modname is set to NULL if it's in the kernel.
  286. * - We guarantee that the returned name is valid until we reschedule even if.
  287. * It resides in a module.
  288. * - We also guarantee that modname will be valid until rescheduled.
  289. */
  290. const char *kallsyms_lookup(unsigned long addr,
  291. unsigned long *symbolsize,
  292. unsigned long *offset,
  293. char **modname, char *namebuf)
  294. {
  295. const char *ret;
  296. namebuf[KSYM_NAME_LEN - 1] = 0;
  297. namebuf[0] = 0;
  298. if (is_ksym_addr(addr)) {
  299. unsigned long pos;
  300. pos = get_symbol_pos(addr, symbolsize, offset);
  301. /* Grab name */
  302. kallsyms_expand_symbol(get_symbol_offset(pos),
  303. namebuf, KSYM_NAME_LEN);
  304. if (modname)
  305. *modname = NULL;
  306. ret = namebuf;
  307. goto found;
  308. }
  309. /* See if it's in a module or a BPF JITed image. */
  310. ret = module_address_lookup(addr, symbolsize, offset,
  311. modname, namebuf);
  312. if (!ret)
  313. ret = bpf_address_lookup(addr, symbolsize,
  314. offset, modname, namebuf);
  315. found:
  316. cleanup_symbol_name(namebuf);
  317. return ret;
  318. }
  319. int lookup_symbol_name(unsigned long addr, char *symname)
  320. {
  321. int res;
  322. symname[0] = '\0';
  323. symname[KSYM_NAME_LEN - 1] = '\0';
  324. if (is_ksym_addr(addr)) {
  325. unsigned long pos;
  326. pos = get_symbol_pos(addr, NULL, NULL);
  327. /* Grab name */
  328. kallsyms_expand_symbol(get_symbol_offset(pos),
  329. symname, KSYM_NAME_LEN);
  330. goto found;
  331. }
  332. /* See if it's in a module. */
  333. res = lookup_module_symbol_name(addr, symname);
  334. if (res)
  335. return res;
  336. found:
  337. cleanup_symbol_name(symname);
  338. return 0;
  339. }
  340. int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
  341. unsigned long *offset, char *modname, char *name)
  342. {
  343. int res;
  344. name[0] = '\0';
  345. name[KSYM_NAME_LEN - 1] = '\0';
  346. if (is_ksym_addr(addr)) {
  347. unsigned long pos;
  348. pos = get_symbol_pos(addr, size, offset);
  349. /* Grab name */
  350. kallsyms_expand_symbol(get_symbol_offset(pos),
  351. name, KSYM_NAME_LEN);
  352. modname[0] = '\0';
  353. goto found;
  354. }
  355. /* See if it's in a module. */
  356. res = lookup_module_symbol_attrs(addr, size, offset, modname, name);
  357. if (res)
  358. return res;
  359. found:
  360. cleanup_symbol_name(name);
  361. return 0;
  362. }
  363. /* Look up a kernel symbol and return it in a text buffer. */
  364. static int __sprint_symbol(char *buffer, unsigned long address,
  365. int symbol_offset, int add_offset)
  366. {
  367. char *modname;
  368. const char *name;
  369. unsigned long offset, size;
  370. int len;
  371. address += symbol_offset;
  372. name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
  373. if (!name)
  374. return sprintf(buffer, "0x%lx", address - symbol_offset);
  375. if (name != buffer)
  376. strcpy(buffer, name);
  377. len = strlen(buffer);
  378. offset -= symbol_offset;
  379. if (add_offset)
  380. len += sprintf(buffer + len, "+%#lx/%#lx", offset, size);
  381. if (modname)
  382. len += sprintf(buffer + len, " [%s]", modname);
  383. return len;
  384. }
  385. /**
  386. * sprint_symbol - Look up a kernel symbol and return it in a text buffer
  387. * @buffer: buffer to be stored
  388. * @address: address to lookup
  389. *
  390. * This function looks up a kernel symbol with @address and stores its name,
  391. * offset, size and module name to @buffer if possible. If no symbol was found,
  392. * just saves its @address as is.
  393. *
  394. * This function returns the number of bytes stored in @buffer.
  395. */
  396. int sprint_symbol(char *buffer, unsigned long address)
  397. {
  398. return __sprint_symbol(buffer, address, 0, 1);
  399. }
  400. EXPORT_SYMBOL_GPL(sprint_symbol);
  401. /**
  402. * sprint_symbol_no_offset - Look up a kernel symbol and return it in a text buffer
  403. * @buffer: buffer to be stored
  404. * @address: address to lookup
  405. *
  406. * This function looks up a kernel symbol with @address and stores its name
  407. * and module name to @buffer if possible. If no symbol was found, just saves
  408. * its @address as is.
  409. *
  410. * This function returns the number of bytes stored in @buffer.
  411. */
  412. int sprint_symbol_no_offset(char *buffer, unsigned long address)
  413. {
  414. return __sprint_symbol(buffer, address, 0, 0);
  415. }
  416. EXPORT_SYMBOL_GPL(sprint_symbol_no_offset);
  417. /**
  418. * sprint_backtrace - Look up a backtrace symbol and return it in a text buffer
  419. * @buffer: buffer to be stored
  420. * @address: address to lookup
  421. *
  422. * This function is for stack backtrace and does the same thing as
  423. * sprint_symbol() but with modified/decreased @address. If there is a
  424. * tail-call to the function marked "noreturn", gcc optimized out code after
  425. * the call so that the stack-saved return address could point outside of the
  426. * caller. This function ensures that kallsyms will find the original caller
  427. * by decreasing @address.
  428. *
  429. * This function returns the number of bytes stored in @buffer.
  430. */
  431. int sprint_backtrace(char *buffer, unsigned long address)
  432. {
  433. return __sprint_symbol(buffer, address, -1, 1);
  434. }
  435. /* Look up a kernel symbol and print it to the kernel messages. */
  436. void __print_symbol(const char *fmt, unsigned long address)
  437. {
  438. char buffer[KSYM_SYMBOL_LEN];
  439. sprint_symbol(buffer, address);
  440. printk(fmt, buffer);
  441. }
  442. EXPORT_SYMBOL(__print_symbol);
  443. /* To avoid using get_symbol_offset for every symbol, we carry prefix along. */
  444. struct kallsym_iter {
  445. loff_t pos;
  446. loff_t pos_mod_end;
  447. unsigned long value;
  448. unsigned int nameoff; /* If iterating in core kernel symbols. */
  449. char type;
  450. char name[KSYM_NAME_LEN];
  451. char module_name[MODULE_NAME_LEN];
  452. int exported;
  453. };
  454. static int get_ksymbol_mod(struct kallsym_iter *iter)
  455. {
  456. int ret = module_get_kallsym(iter->pos - kallsyms_num_syms,
  457. &iter->value, &iter->type,
  458. iter->name, iter->module_name,
  459. &iter->exported);
  460. if (ret < 0) {
  461. iter->pos_mod_end = iter->pos;
  462. return 0;
  463. }
  464. return 1;
  465. }
  466. static int get_ksymbol_bpf(struct kallsym_iter *iter)
  467. {
  468. iter->module_name[0] = '\0';
  469. iter->exported = 0;
  470. return bpf_get_kallsym(iter->pos - iter->pos_mod_end,
  471. &iter->value, &iter->type,
  472. iter->name) < 0 ? 0 : 1;
  473. }
  474. /* Returns space to next name. */
  475. static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
  476. {
  477. unsigned off = iter->nameoff;
  478. iter->module_name[0] = '\0';
  479. iter->value = kallsyms_sym_address(iter->pos);
  480. iter->type = kallsyms_get_symbol_type(off);
  481. off = kallsyms_expand_symbol(off, iter->name, ARRAY_SIZE(iter->name));
  482. return off - iter->nameoff;
  483. }
  484. static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
  485. {
  486. iter->name[0] = '\0';
  487. iter->nameoff = get_symbol_offset(new_pos);
  488. iter->pos = new_pos;
  489. if (new_pos == 0)
  490. iter->pos_mod_end = 0;
  491. }
  492. static int update_iter_mod(struct kallsym_iter *iter, loff_t pos)
  493. {
  494. iter->pos = pos;
  495. if (iter->pos_mod_end > 0 &&
  496. iter->pos_mod_end < iter->pos)
  497. return get_ksymbol_bpf(iter);
  498. if (!get_ksymbol_mod(iter))
  499. return get_ksymbol_bpf(iter);
  500. return 1;
  501. }
  502. /* Returns false if pos at or past end of file. */
  503. static int update_iter(struct kallsym_iter *iter, loff_t pos)
  504. {
  505. /* Module symbols can be accessed randomly. */
  506. if (pos >= kallsyms_num_syms)
  507. return update_iter_mod(iter, pos);
  508. /* If we're not on the desired position, reset to new position. */
  509. if (pos != iter->pos)
  510. reset_iter(iter, pos);
  511. iter->nameoff += get_ksymbol_core(iter);
  512. iter->pos++;
  513. return 1;
  514. }
  515. static void *s_next(struct seq_file *m, void *p, loff_t *pos)
  516. {
  517. (*pos)++;
  518. if (!update_iter(m->private, *pos))
  519. return NULL;
  520. return p;
  521. }
  522. static void *s_start(struct seq_file *m, loff_t *pos)
  523. {
  524. if (!update_iter(m->private, *pos))
  525. return NULL;
  526. return m->private;
  527. }
  528. static void s_stop(struct seq_file *m, void *p)
  529. {
  530. }
  531. static int s_show(struct seq_file *m, void *p)
  532. {
  533. struct kallsym_iter *iter = m->private;
  534. /* Some debugging symbols have no name. Ignore them. */
  535. if (!iter->name[0])
  536. return 0;
  537. if (iter->module_name[0]) {
  538. char type;
  539. /*
  540. * Label it "global" if it is exported,
  541. * "local" if not exported.
  542. */
  543. type = iter->exported ? toupper(iter->type) :
  544. tolower(iter->type);
  545. seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
  546. type, iter->name, iter->module_name);
  547. } else
  548. seq_printf(m, "%pK %c %s\n", (void *)iter->value,
  549. iter->type, iter->name);
  550. return 0;
  551. }
  552. static const struct seq_operations kallsyms_op = {
  553. .start = s_start,
  554. .next = s_next,
  555. .stop = s_stop,
  556. .show = s_show
  557. };
  558. static int kallsyms_open(struct inode *inode, struct file *file)
  559. {
  560. /*
  561. * We keep iterator in m->private, since normal case is to
  562. * s_start from where we left off, so we avoid doing
  563. * using get_symbol_offset for every symbol.
  564. */
  565. struct kallsym_iter *iter;
  566. iter = __seq_open_private(file, &kallsyms_op, sizeof(*iter));
  567. if (!iter)
  568. return -ENOMEM;
  569. reset_iter(iter, 0);
  570. return 0;
  571. }
  572. #ifdef CONFIG_KGDB_KDB
  573. const char *kdb_walk_kallsyms(loff_t *pos)
  574. {
  575. static struct kallsym_iter kdb_walk_kallsyms_iter;
  576. if (*pos == 0) {
  577. memset(&kdb_walk_kallsyms_iter, 0,
  578. sizeof(kdb_walk_kallsyms_iter));
  579. reset_iter(&kdb_walk_kallsyms_iter, 0);
  580. }
  581. while (1) {
  582. if (!update_iter(&kdb_walk_kallsyms_iter, *pos))
  583. return NULL;
  584. ++*pos;
  585. /* Some debugging symbols have no name. Ignore them. */
  586. if (kdb_walk_kallsyms_iter.name[0])
  587. return kdb_walk_kallsyms_iter.name;
  588. }
  589. }
  590. #endif /* CONFIG_KGDB_KDB */
  591. static const struct file_operations kallsyms_operations = {
  592. .open = kallsyms_open,
  593. .read = seq_read,
  594. .llseek = seq_lseek,
  595. .release = seq_release_private,
  596. };
  597. static int __init kallsyms_init(void)
  598. {
  599. proc_create("kallsyms", 0444, NULL, &kallsyms_operations);
  600. return 0;
  601. }
  602. device_initcall(kallsyms_init);