2
0

220-module_exports.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. --- a/include/asm-generic/vmlinux.lds.h
  2. +++ b/include/asm-generic/vmlinux.lds.h
  3. @@ -52,6 +52,27 @@
  4. #define LOAD_OFFSET 0
  5. #endif
  6. +#ifndef SYMTAB_KEEP_STR
  7. +#define SYMTAB_KEEP_STR *(__ksymtab_strings+*)
  8. +#define SYMTAB_DISCARD_STR
  9. +#else
  10. +#define SYMTAB_DISCARD_STR *(__ksymtab_strings+*)
  11. +#endif
  12. +
  13. +#ifndef SYMTAB_KEEP
  14. +#define SYMTAB_KEEP *(SORT(___ksymtab+*))
  15. +#define SYMTAB_DISCARD
  16. +#else
  17. +#define SYMTAB_DISCARD *(SORT(___ksymtab+*))
  18. +#endif
  19. +
  20. +#ifndef SYMTAB_KEEP_GPL
  21. +#define SYMTAB_KEEP_GPL *(SORT(___ksymtab_gpl+*))
  22. +#define SYMTAB_DISCARD_GPL
  23. +#else
  24. +#define SYMTAB_DISCARD_GPL *(SORT(___ksymtab_gpl+*))
  25. +#endif
  26. +
  27. #ifndef SYMBOL_PREFIX
  28. #define VMLINUX_SYMBOL(sym) sym
  29. #else
  30. @@ -276,14 +297,14 @@
  31. /* Kernel symbol table: Normal symbols */ \
  32. __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
  33. VMLINUX_SYMBOL(__start___ksymtab) = .; \
  34. - *(SORT(___ksymtab+*)) \
  35. + SYMTAB_KEEP \
  36. VMLINUX_SYMBOL(__stop___ksymtab) = .; \
  37. } \
  38. \
  39. /* Kernel symbol table: GPL-only symbols */ \
  40. __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
  41. VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
  42. - *(SORT(___ksymtab_gpl+*)) \
  43. + SYMTAB_KEEP_GPL \
  44. VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
  45. } \
  46. \
  47. @@ -345,7 +366,7 @@
  48. \
  49. /* Kernel symbol table: strings */ \
  50. __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
  51. - *(__ksymtab_strings) \
  52. + SYMTAB_KEEP_STR \
  53. } \
  54. \
  55. /* __*init sections */ \
  56. @@ -677,6 +698,9 @@
  57. EXIT_TEXT \
  58. EXIT_DATA \
  59. EXIT_CALL \
  60. + SYMTAB_DISCARD \
  61. + SYMTAB_DISCARD_GPL \
  62. + SYMTAB_DISCARD_STR \
  63. *(.discard) \
  64. *(.discard.*) \
  65. }
  66. --- a/include/linux/module.h
  67. +++ b/include/linux/module.h
  68. @@ -230,12 +230,19 @@ struct module_use {
  69. #define __CRC_SYMBOL(sym, sec)
  70. #endif
  71. +#ifdef MODULE
  72. +#define __EXPORT_SUFFIX(sym)
  73. +#else
  74. +#define __EXPORT_SUFFIX(sym) "+" #sym
  75. +#endif
  76. +
  77. /* For every exported symbol, place a struct in the __ksymtab section */
  78. #define __EXPORT_SYMBOL(sym, sec) \
  79. extern typeof(sym) sym; \
  80. __CRC_SYMBOL(sym, sec) \
  81. static const char __kstrtab_##sym[] \
  82. - __attribute__((section("__ksymtab_strings"), aligned(1))) \
  83. + __attribute__((section("__ksymtab_strings" \
  84. + __EXPORT_SUFFIX(sym)), aligned(1))) \
  85. = MODULE_SYMBOL_PREFIX #sym; \
  86. static const struct kernel_symbol __ksymtab_##sym \
  87. __used \