kallsyms.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Rewritten and vastly simplified by Rusty Russell for in-kernel
  2. * module loader:
  3. * Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
  4. */
  5. #ifndef _LINUX_KALLSYMS_H
  6. #define _LINUX_KALLSYMS_H
  7. #define KSYM_NAME_LEN 127
  8. #ifdef CONFIG_KALLSYMS
  9. /* Lookup the address for a symbol. Returns 0 if not found. */
  10. unsigned long kallsyms_lookup_name(const char *name);
  11. extern int kallsyms_lookup_size_offset(unsigned long addr,
  12. unsigned long *symbolsize,
  13. unsigned long *offset);
  14. /* Lookup an address. modname is set to NULL if it's in the kernel. */
  15. const char *kallsyms_lookup(unsigned long addr,
  16. unsigned long *symbolsize,
  17. unsigned long *offset,
  18. char **modname, char *namebuf);
  19. /* Replace "%s" in format with address, if found */
  20. extern void __print_symbol(const char *fmt, unsigned long address);
  21. #else /* !CONFIG_KALLSYMS */
  22. static inline unsigned long kallsyms_lookup_name(const char *name)
  23. {
  24. return 0;
  25. }
  26. static inline int kallsyms_lookup_size_offset(unsigned long addr,
  27. unsigned long *symbolsize,
  28. unsigned long *offset)
  29. {
  30. return 0;
  31. }
  32. static inline const char *kallsyms_lookup(unsigned long addr,
  33. unsigned long *symbolsize,
  34. unsigned long *offset,
  35. char **modname, char *namebuf)
  36. {
  37. return NULL;
  38. }
  39. /* Stupid that this does nothing, but I didn't create this mess. */
  40. #define __print_symbol(fmt, addr)
  41. #endif /*CONFIG_KALLSYMS*/
  42. /* This macro allows us to keep printk typechecking */
  43. static void __check_printsym_format(const char *fmt, ...)
  44. __attribute__((format(printf,1,2)));
  45. static inline void __check_printsym_format(const char *fmt, ...)
  46. {
  47. }
  48. /* ia64 and ppc64 use function descriptors, which contain the real address */
  49. #if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
  50. #define print_fn_descriptor_symbol(fmt, addr) \
  51. do { \
  52. unsigned long *__faddr = (unsigned long*) addr; \
  53. print_symbol(fmt, __faddr[0]); \
  54. } while (0)
  55. #else
  56. #define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
  57. #endif
  58. static inline void print_symbol(const char *fmt, unsigned long addr)
  59. {
  60. __check_printsym_format(fmt, "");
  61. __print_symbol(fmt, (unsigned long)
  62. __builtin_extract_return_addr((void *)addr));
  63. }
  64. #ifndef CONFIG_64BIT
  65. #define print_ip_sym(ip) \
  66. do { \
  67. printk("[<%08lx>]", ip); \
  68. print_symbol(" %s\n", ip); \
  69. } while(0)
  70. #else
  71. #define print_ip_sym(ip) \
  72. do { \
  73. printk("[<%016lx>]", ip); \
  74. print_symbol(" %s\n", ip); \
  75. } while(0)
  76. #endif
  77. #endif /*_LINUX_KALLSYMS_H*/