1
0

221-module_exports.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. --- a/include/asm-generic/vmlinux.lds.h
  2. +++ b/include/asm-generic/vmlinux.lds.h
  3. @@ -54,6 +54,16 @@
  4. #define LOAD_OFFSET 0
  5. #endif
  6. +#ifndef SYMTAB_KEEP
  7. +#define SYMTAB_KEEP KEEP(*(SORT(___ksymtab+*)))
  8. +#define SYMTAB_KEEP_GPL KEEP(*(SORT(___ksymtab_gpl+*)))
  9. +#endif
  10. +
  11. +#ifndef SYMTAB_DISCARD
  12. +#define SYMTAB_DISCARD
  13. +#define SYMTAB_DISCARD_GPL
  14. +#endif
  15. +
  16. #include <linux/export.h>
  17. /* Align . to a 8 byte boundary equals to maximum function alignment. */
  18. @@ -311,14 +321,14 @@
  19. /* Kernel symbol table: Normal symbols */ \
  20. __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
  21. VMLINUX_SYMBOL(__start___ksymtab) = .; \
  22. - KEEP(*(SORT(___ksymtab+*))) \
  23. + SYMTAB_KEEP \
  24. VMLINUX_SYMBOL(__stop___ksymtab) = .; \
  25. } \
  26. \
  27. /* Kernel symbol table: GPL-only symbols */ \
  28. __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
  29. VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
  30. - KEEP(*(SORT(___ksymtab_gpl+*))) \
  31. + SYMTAB_KEEP_GPL \
  32. VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
  33. } \
  34. \
  35. @@ -380,7 +390,7 @@
  36. \
  37. /* Kernel symbol table: strings */ \
  38. __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
  39. - *(__ksymtab_strings) \
  40. + *(__ksymtab_strings+*) \
  41. } \
  42. \
  43. /* __*init sections */ \
  44. @@ -710,6 +720,8 @@
  45. EXIT_TEXT \
  46. EXIT_DATA \
  47. EXIT_CALL \
  48. + SYMTAB_DISCARD \
  49. + SYMTAB_DISCARD_GPL \
  50. *(.discard) \
  51. *(.discard.*) \
  52. }
  53. --- a/scripts/Makefile.build
  54. +++ b/scripts/Makefile.build
  55. @@ -372,7 +372,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(
  56. # Linker scripts preprocessor (.lds.S -> .lds)
  57. # ---------------------------------------------------------------------------
  58. quiet_cmd_cpp_lds_S = LDS $@
  59. - cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
  60. + cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
  61. -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
  62. $(obj)/%.lds: $(src)/%.lds.S FORCE
  63. --- a/include/linux/export.h
  64. +++ b/include/linux/export.h
  65. @@ -52,12 +52,19 @@ extern struct module __this_module;
  66. #define __CRC_SYMBOL(sym, sec)
  67. #endif
  68. +#ifdef MODULE
  69. +#define __EXPORT_SUFFIX(sym)
  70. +#else
  71. +#define __EXPORT_SUFFIX(sym) "+" #sym
  72. +#endif
  73. +
  74. /* For every exported symbol, place a struct in the __ksymtab section */
  75. #define __EXPORT_SYMBOL(sym, sec) \
  76. extern typeof(sym) sym; \
  77. __CRC_SYMBOL(sym, sec) \
  78. static const char __kstrtab_##sym[] \
  79. - __attribute__((section("__ksymtab_strings"), aligned(1))) \
  80. + __attribute__((section("__ksymtab_strings" \
  81. + __EXPORT_SUFFIX(sym)), aligned(1))) \
  82. = VMLINUX_SYMBOL_STR(sym); \
  83. extern const struct kernel_symbol __ksymtab_##sym; \
  84. __visible const struct kernel_symbol __ksymtab_##sym \