common-rom.cmake 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. # originates from common-rom.ld
  2. zephyr_linker_section(NAME init KVMA RAM_REGION GROUP RODATA_REGION)
  3. zephyr_linker_section_obj_level(SECTION init LEVEL PRE_KERNEL_1)
  4. zephyr_linker_section_obj_level(SECTION init LEVEL PRE_KERNEL_2)
  5. zephyr_linker_section_obj_level(SECTION init LEVEL POST_KERNEL)
  6. zephyr_linker_section_obj_level(SECTION init LEVEL APPLICATION)
  7. zephyr_linker_section_obj_level(SECTION init LEVEL SMP)
  8. zephyr_linker_section(NAME device KVMA RAM_REGION GROUP RODATA_REGION)
  9. zephyr_linker_section_obj_level(SECTION device LEVEL PRE_KERNEL_1)
  10. zephyr_linker_section_obj_level(SECTION device LEVEL PRE_KERNEL_2)
  11. zephyr_linker_section_obj_level(SECTION device LEVEL POST_KERNEL)
  12. zephyr_linker_section_obj_level(SECTION device LEVEL APPLICATION)
  13. zephyr_linker_section_obj_level(SECTION device LEVEL SMP)
  14. if(CONFIG_GEN_SW_ISR_TABLE AND NOT CONFIG_DYNAMIC_INTERRUPTS)
  15. # ld align has been changed to subalign to provide identical behavior scatter vs. ld.
  16. zephyr_linker_section(NAME sw_isr_table KVMA FLASH GROUP RODATA_REGION SUBALIGN ${CONFIG_ARCH_SW_ISR_TABLE_ALIGN} NOINPUT)
  17. zephyr_linker_section_configure(
  18. SECTION sw_isr_table
  19. INPUT ".gnu.linkonce.sw_isr_table*"
  20. )
  21. endif()
  22. zephyr_linker_section(NAME initlevel_error KVMA RAM_REGION GROUP RODATA_REGION NOINPUT)
  23. zephyr_linker_section_configure(SECTION initlevel_error INPUT ".z_init_[_A-Z0-9]*" KEEP SORT NAME)
  24. # How to do cross linker ?
  25. # ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.")
  26. if(CONFIG_CPLUSPLUS)
  27. zephyr_linker_section(NAME ctors KVMA RAM_REGION GROUP RODATA_REGION NOINPUT)
  28. #
  29. # The compiler fills the constructor pointers table below,
  30. # hence symbol __CTOR_LIST__ must be aligned on word
  31. # boundary. To align with the C++ standard, the first elment
  32. # of the array contains the number of actual constructors. The
  33. # last element is NULL.
  34. #
  35. # ToDo: Checkup on scatter loading. How to manage ?
  36. # https://www.keil.com/support/man/docs/armlink/armlink_pge1362066006368.htm
  37. # https://developer.arm.com/documentation/dui0378/g/The-ARM-C-and-C---Libraries
  38. # if(CONFIG_64BIT)
  39. # . = ALIGN(8);
  40. # __CTOR_LIST__ = .;
  41. # QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
  42. # KEEP(*(SORT_BY_NAME(".ctors*")))
  43. # QUAD(0)
  44. # __CTOR_END__ = .;
  45. # else()
  46. # . = ALIGN(4);
  47. # __CTOR_LIST__ = .;
  48. # LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
  49. # KEEP(*(SORT_BY_NAME(".ctors*")))
  50. # LONG(0)
  51. # __CTOR_END__ = .;
  52. # endif()
  53. # } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
  54. #
  55. # SECTION_PROLOGUE(init_array,,)
  56. # {
  57. # . = ALIGN(4);
  58. # __init_array_start = .;
  59. # KEEP(*(SORT_BY_NAME(".init_array*")))
  60. # __init_array_end = .;
  61. # } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
  62. endif()
  63. if(CONFIG_USERSPACE)
  64. # Build-time assignment of permissions to kernel objects to
  65. # threads declared with K_THREAD_DEFINE()
  66. zephyr_linker_section(
  67. NAME z_object_assignment_area
  68. VMA FLASH NOINPUT
  69. SUBALIGN 4
  70. )
  71. zephyr_linker_section_configure(
  72. SECTION z_object_assignment
  73. INPUT ".z_object_assignment.static.*"
  74. KEEP SORT NAME
  75. )
  76. endif()
  77. zephyr_linker_section(
  78. NAME app_shmem_regions
  79. KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT}
  80. )
  81. zephyr_linker_section_configure(
  82. SECTION app_shmem_regions
  83. INPUT ".app_regions.*"
  84. KEEP SORT NAME
  85. )
  86. if(CONFIG_NET_SOCKETS)
  87. zephyr_iterable_section(NAME net_socket_register KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  88. endif()
  89. if(CONFIG_NET_L2_PPP)
  90. zephyr_iterable_section(NAME ppp_protocol_handler KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  91. endif()
  92. zephyr_iterable_section(NAME bt_l2cap_fixed_chan KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  93. if(CONFIG_BT_BREDR)
  94. zephyr_iterable_section(NAME bt_l2cap_br_fixed_chan KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  95. endif()
  96. if(CONFIG_BT_CONN)
  97. zephyr_iterable_section(NAME bt_conn_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  98. endif()
  99. zephyr_iterable_section(NAME bt_gatt_service_static KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  100. if(CONFIG_BT_MESH)
  101. zephyr_iterable_section(NAME bt_mesh_subnet_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  102. zephyr_iterable_section(NAME bt_mesh_app_key_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  103. zephyr_iterable_section(NAME bt_mesh_hb_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  104. endif()
  105. if(CONFIG_BT_MESH_FRIEND)
  106. zephyr_iterable_section(NAME bt_mesh_friend_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  107. endif()
  108. if(CONFIG_BT_MESH_LOW_POWER)
  109. zephyr_iterable_section(NAME bt_mesh_lpn_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  110. endif()
  111. if(CONFIG_BT_MESH_PROXY)
  112. zephyr_iterable_section(NAME bt_mesh_proxy_cb KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  113. endif()
  114. if(CONFIG_EC_HOST_CMD)
  115. zephyr_iterable_section(NAME ec_host_cmd_handler KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  116. endif()
  117. if(CONFIG_SETTINGS)
  118. zephyr_iterable_section(NAME settings_handler_static KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  119. endif()
  120. zephyr_iterable_section(NAME k_p4wq_initparam KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  121. if(CONFIG_EMUL)
  122. zephyr_linker_section(NAME emulators_section GROUP RODATA_REGION)
  123. zephyr_linker_section_configure(SECTION emulators_section INPUT ".emulators" KEEP SORT NAME ${XIP_ALIGN_WITH_INPUT})
  124. endif()
  125. if(CONFIG_DNS_SD)
  126. zephyr_iterable_section(NAME dns_sd_rec KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  127. endif()
  128. if(CONFIG_PCIE)
  129. zephyr_linker_section(NAME irq_alloc GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  130. zephyr_linker_section_configure(SECTION irq_alloc INPUT ".irq_alloc*" KEEP SORT NAME)
  131. endif()
  132. zephyr_linker_section(NAME log_strings KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  133. zephyr_linker_section_configure(SECTION log_strings INPUT ".log_strings*" KEEP SORT NAME)
  134. zephyr_linker_section(NAME log_const KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  135. zephyr_linker_section_configure(SECTION log_const INPUT ".log_const_*" KEEP SORT NAME)
  136. zephyr_linker_section(NAME log_backends KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  137. zephyr_linker_section_configure(SECTION log_backends INPUT ".log_backends.*" KEEP)
  138. zephyr_iterable_section(NAME shell KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  139. zephyr_linker_section(NAME shell_root_cmds KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  140. zephyr_linker_section_configure(SECTION shell_root_cmds INPUT ".shell_root_cmd_*" KEEP SORT NAME)
  141. zephyr_linker_section(NAME font_entry KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  142. zephyr_linker_section_configure(SECTION font_entry INPUT "._cfb_font.*" KEEP SORT NAME)
  143. zephyr_iterable_section(NAME tracing_backend KVMA RAM_REGION GROUP RODATA_REGION SUBALIGN 4)
  144. zephyr_linker_section(NAME zephyr_dbg_info KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT})
  145. zephyr_linker_section_configure(SECTION zephyr_dbg_info INPUT ".zephyr_dbg_info" KEEP)
  146. zephyr_linker_section(NAME device_handles KVMA RAM_REGION GROUP RODATA_REGION NOINPUT ${XIP_ALIGN_WITH_INPUT} ENDALIGN 16)
  147. zephyr_linker_section_configure(SECTION device_handles INPUT .__device_handles_pass1* KEEP SORT NAME PASS 1)
  148. zephyr_linker_section_configure(SECTION device_handles INPUT .__device_handles_pass2* KEEP SORT NAME PASS 2)