export.h 2.1 KB

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