kallsyms.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include <linux/config.h>
  8. #define KSYM_NAME_LEN 127
  9. #ifdef CONFIG_KALLSYMS
  10. /* Lookup the address for a symbol. Returns 0 if not found. */
  11. unsigned long kallsyms_lookup_name(const char *name);
  12. /* Lookup an address. modname is set to NULL if it's in the kernel. */
  13. const char *kallsyms_lookup(unsigned long addr,
  14. unsigned long *symbolsize,
  15. unsigned long *offset,
  16. char **modname, char *namebuf);
  17. /* Replace "%s" in format with address, if found */
  18. extern void __print_symbol(const char *fmt, unsigned long address);
  19. #else /* !CONFIG_KALLSYMS */
  20. static inline unsigned long kallsyms_lookup_name(const char *name)
  21. {
  22. return 0;
  23. }
  24. static inline const char *kallsyms_lookup(unsigned long addr,
  25. unsigned long *symbolsize,
  26. unsigned long *offset,
  27. char **modname, char *namebuf)
  28. {
  29. return NULL;
  30. }
  31. /* Stupid that this does nothing, but I didn't create this mess. */
  32. #define __print_symbol(fmt, addr)
  33. #endif /*CONFIG_KALLSYMS*/
  34. /* This macro allows us to keep printk typechecking */
  35. static void __check_printsym_format(const char *fmt, ...)
  36. __attribute__((format(printf,1,2)));
  37. static inline void __check_printsym_format(const char *fmt, ...)
  38. {
  39. }
  40. /* ia64 and ppc64 use function descriptors, which contain the real address */
  41. #if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
  42. #define print_fn_descriptor_symbol(fmt, addr) \
  43. do { \
  44. unsigned long *__faddr = (unsigned long*) addr; \
  45. print_symbol(fmt, __faddr[0]); \
  46. } while (0)
  47. #else
  48. #define print_fn_descriptor_symbol(fmt, addr) print_symbol(fmt, addr)
  49. #endif
  50. #define print_symbol(fmt, addr) \
  51. do { \
  52. __check_printsym_format(fmt, ""); \
  53. __print_symbol(fmt, addr); \
  54. } while(0)
  55. #endif /*_LINUX_KALLSYMS_H*/