export.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __ASM_GENERIC_EXPORT_H
  2. #define __ASM_GENERIC_EXPORT_H
  3. #ifndef KSYM_FUNC
  4. #define KSYM_FUNC(x) x
  5. #endif
  6. #ifdef CONFIG_64BIT
  7. #define __put .quad
  8. #ifndef KSYM_ALIGN
  9. #define KSYM_ALIGN 8
  10. #endif
  11. #else
  12. #define __put .long
  13. #ifndef KSYM_ALIGN
  14. #define KSYM_ALIGN 4
  15. #endif
  16. #endif
  17. #ifndef KCRC_ALIGN
  18. #define KCRC_ALIGN 4
  19. #endif
  20. /*
  21. * note on .section use: @progbits vs %progbits nastiness doesn't matter,
  22. * since we immediately emit into those sections anyway.
  23. */
  24. .macro ___EXPORT_SYMBOL name,val,sec
  25. #ifdef CONFIG_MODULES
  26. .globl __ksymtab_\name
  27. .section ___ksymtab\sec+\name,"a"
  28. .balign KSYM_ALIGN
  29. __ksymtab_\name:
  30. __put \val, __kstrtab_\name
  31. .previous
  32. .section __ksymtab_strings,"a"
  33. __kstrtab_\name:
  34. .asciz "\name"
  35. .previous
  36. #ifdef CONFIG_MODVERSIONS
  37. .section ___kcrctab\sec+\name,"a"
  38. .balign KCRC_ALIGN
  39. __kcrctab_\name:
  40. #if defined(CONFIG_MODULE_REL_CRCS)
  41. .long __crc_\name - .
  42. #else
  43. .long __crc_\name
  44. #endif
  45. .weak __crc_\name
  46. .previous
  47. #endif
  48. #endif
  49. .endm
  50. #undef __put
  51. #if defined(__KSYM_DEPS__)
  52. #define __EXPORT_SYMBOL(sym, val, sec) === __KSYM_##sym ===
  53. #elif defined(CONFIG_TRIM_UNUSED_KSYMS)
  54. #include <linux/kconfig.h>
  55. #include <generated/autoksyms.h>
  56. #define __EXPORT_SYMBOL(sym, val, sec) \
  57. __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
  58. #define __cond_export_sym(sym, val, sec, conf) \
  59. ___cond_export_sym(sym, val, sec, conf)
  60. #define ___cond_export_sym(sym, val, sec, enabled) \
  61. __cond_export_sym_##enabled(sym, val, sec)
  62. #define __cond_export_sym_1(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
  63. #define __cond_export_sym_0(sym, val, sec) /* nothing */
  64. #else
  65. #define __EXPORT_SYMBOL(sym, val, sec) ___EXPORT_SYMBOL sym, val, sec
  66. #endif
  67. #define EXPORT_SYMBOL(name) \
  68. __EXPORT_SYMBOL(name, KSYM_FUNC(name),)
  69. #define EXPORT_SYMBOL_GPL(name) \
  70. __EXPORT_SYMBOL(name, KSYM_FUNC(name), _gpl)
  71. #define EXPORT_DATA_SYMBOL(name) \
  72. __EXPORT_SYMBOL(name, name,)
  73. #define EXPORT_DATA_SYMBOL_GPL(name) \
  74. __EXPORT_SYMBOL(name, name,_gpl)
  75. #endif