module.lds.S 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Common module linker script, always used when linking a module.
  3. * Archs are free to supply their own linker scripts. ld will
  4. * combine them automatically.
  5. */
  6. #ifdef CONFIG_UNWIND_TABLES
  7. #define DISCARD_EH_FRAME
  8. #else
  9. #define DISCARD_EH_FRAME *(.eh_frame)
  10. #endif
  11. SECTIONS {
  12. /DISCARD/ : {
  13. *(.discard)
  14. *(.discard.*)
  15. }
  16. __ksymtab 0 : { *(SORT(___ksymtab+*)) }
  17. __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
  18. __kcrctab 0 : { *(SORT(___kcrctab+*)) }
  19. __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
  20. .ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
  21. .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
  22. .altinstructions 0 : ALIGN(8) { KEEP(*(.altinstructions)) }
  23. __bug_table 0 : ALIGN(8) { KEEP(*(__bug_table)) }
  24. __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }
  25. __patchable_function_entries : { *(__patchable_function_entries) }
  26. #ifdef CONFIG_ARCH_USES_CFI_TRAPS
  27. __kcfi_traps : { KEEP(*(.kcfi_traps)) }
  28. #endif
  29. #if IS_ENABLED(CONFIG_CRYPTO_FIPS140_MOD)
  30. /*
  31. * The FIPS140 module incorporates copies of builtin code, which gets
  32. * integrity checked at module load time, and registered in a way that
  33. * ensures that the integrity checked versions supersede the builtin
  34. * ones. These objects are compiled as builtin code, and so their init
  35. * hooks will be exported from the binary in the same way as builtin
  36. * initcalls are, i.e., annotated with a level that defines the order
  37. * in which the hooks are expected to be invoked.
  38. */
  39. #define INIT_CALLS_LEVEL(level) \
  40. KEEP(*(.initcall##level##.init*)) \
  41. KEEP(*(.initcall##level##s.init*))
  42. .initcalls : {
  43. *(.initcalls._start)
  44. INIT_CALLS_LEVEL(0)
  45. INIT_CALLS_LEVEL(1)
  46. INIT_CALLS_LEVEL(2)
  47. INIT_CALLS_LEVEL(3)
  48. INIT_CALLS_LEVEL(4)
  49. INIT_CALLS_LEVEL(5)
  50. INIT_CALLS_LEVEL(rootfs)
  51. INIT_CALLS_LEVEL(6)
  52. INIT_CALLS_LEVEL(7)
  53. *(.initcalls._end)
  54. }
  55. #endif
  56. #if defined(CONFIG_LTO_CLANG) || IS_ENABLED(CONFIG_CRYPTO_FIPS140_MOD)
  57. /*
  58. * With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and
  59. * -ffunction-sections, which increases the size of the final module.
  60. * Merge the split sections in the final binary.
  61. */
  62. .bss : {
  63. *(.bss .bss.[0-9a-zA-Z_]*)
  64. *(.bss..L*)
  65. }
  66. .data : {
  67. *(.data .data.[0-9a-zA-Z_]*)
  68. *(.data..L*)
  69. }
  70. .rodata : {
  71. *(.rodata.._start)
  72. *(.rodata .rodata.[0-9a-zA-Z_]*)
  73. *(.rodata..L*)
  74. *(.rodata.._end)
  75. }
  76. .text : {
  77. *(.text.._start)
  78. *(.text .text.[0-9a-zA-Z_]*)
  79. *(.text.._end)
  80. *(.text.._fips140_unchecked)
  81. }
  82. #endif
  83. }
  84. /* bring in arch-specific sections */
  85. #include <asm/module.lds.h>