ksyms.h 528 B

12345678910111213141516171819
  1. #ifndef _KSYM_H
  2. #define _KSYM_H
  3. #include <linux/kallsyms.h>
  4. #define __KSYM(name) __ksym_##name
  5. #define KSYM(name) ({ BUG_ON(!__KSYM(name)); __KSYM(name); })
  6. #define IMPORT_KSYM(name) __typeof(name) * __KSYM(name)
  7. #define IMPORT_KSYM_PROTO(name, ret, ...) ret (*__KSYM(name)) (__VA_ARGS__)
  8. #define LOOKUP_KSYM(name) \
  9. do { \
  10. __KSYM(name) = (void *) kallsyms_lookup_name(#name); \
  11. if (!__KSYM(name)) { \
  12. pr_err("Unknown symbol: " #name "\n"); \
  13. return -EINVAL; \
  14. } \
  15. } while (0)
  16. #endif