export.h 2.2 KB

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