sections.ld.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*
  2. * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /* Default entry point */
  7. ENTRY(call_start_cpu0);
  8. SECTIONS
  9. {
  10. /**
  11. * RTC fast memory holds RTC wake stub code,
  12. * including from any source file named rtc_wake_stub*.c
  13. */
  14. .rtc.text :
  15. {
  16. . = ALIGN(4);
  17. mapping[rtc_text]
  18. *rtc_wake_stub*.*(.literal .text .literal.* .text.*)
  19. _rtc_text_end = ABSOLUTE(.);
  20. } > rtc_iram_seg
  21. /**
  22. * This section is required to skip rtc.text area because rtc_iram_seg and
  23. * rtc_data_seg are reflect the same address space on different buses.
  24. */
  25. .rtc.dummy :
  26. {
  27. _rtc_dummy_start = ABSOLUTE(.);
  28. _rtc_fast_start = ABSOLUTE(.);
  29. . = SIZEOF(.rtc.text);
  30. _rtc_dummy_end = ABSOLUTE(.);
  31. } > rtc_data_seg
  32. /**
  33. * This section located in RTC FAST Memory area.
  34. * It holds data marked with RTC_FAST_ATTR attribute.
  35. * See the file "esp_attr.h" for more information.
  36. */
  37. .rtc.force_fast :
  38. {
  39. . = ALIGN(4);
  40. _rtc_force_fast_start = ABSOLUTE(.);
  41. mapping[rtc_force_fast]
  42. *(.rtc.force_fast .rtc.force_fast.*)
  43. . = ALIGN(4) ;
  44. _rtc_force_fast_end = ABSOLUTE(.);
  45. } > rtc_data_seg
  46. /**
  47. * RTC data section holds RTC wake stub
  48. * data/rodata, including from any source file
  49. * named rtc_wake_stub*.c and the data marked with
  50. * RTC_DATA_ATTR, RTC_RODATA_ATTR attributes.
  51. * The memory location of the data is dependent on
  52. * CONFIG_ESP32H2_RTCDATA_IN_FAST_MEM option.
  53. */
  54. .rtc.data :
  55. {
  56. _rtc_data_start = ABSOLUTE(.);
  57. mapping[rtc_data]
  58. *rtc_wake_stub*.*(.data .rodata .data.* .rodata.* .bss .bss.*)
  59. _rtc_data_end = ABSOLUTE(.);
  60. } > rtc_data_location
  61. /* RTC bss, from any source file named rtc_wake_stub*.c */
  62. .rtc.bss (NOLOAD) :
  63. {
  64. _rtc_bss_start = ABSOLUTE(.);
  65. *rtc_wake_stub*.*(.bss .bss.*)
  66. *rtc_wake_stub*.*(COMMON)
  67. mapping[rtc_bss]
  68. _rtc_bss_end = ABSOLUTE(.);
  69. } > rtc_data_location
  70. /**
  71. * This section holds data that should not be initialized at power up
  72. * and will be retained during deep sleep.
  73. * User data marked with RTC_NOINIT_ATTR will be placed
  74. * into this section. See the file "esp_attr.h" for more information.
  75. * The memory location of the data is dependent on CONFIG_ESP32H2_RTCDATA_IN_FAST_MEM option.
  76. */
  77. .rtc_noinit (NOLOAD):
  78. {
  79. . = ALIGN(4);
  80. _rtc_noinit_start = ABSOLUTE(.);
  81. *(.rtc_noinit .rtc_noinit.*)
  82. . = ALIGN(4) ;
  83. _rtc_noinit_end = ABSOLUTE(.);
  84. } > rtc_data_location
  85. /**
  86. * This section located in RTC SLOW Memory area.
  87. * It holds data marked with RTC_SLOW_ATTR attribute.
  88. * See the file "esp_attr.h" for more information.
  89. */
  90. .rtc.force_slow :
  91. {
  92. . = ALIGN(4);
  93. _rtc_force_slow_start = ABSOLUTE(.);
  94. *(.rtc.force_slow .rtc.force_slow.*)
  95. . = ALIGN(4) ;
  96. _rtc_force_slow_end = ABSOLUTE(.);
  97. } > rtc_slow_seg
  98. /* Get size of rtc slow data based on rtc_data_location alias */
  99. _rtc_slow_length = (ORIGIN(rtc_slow_seg) == ORIGIN(rtc_data_location))
  100. ? (_rtc_force_slow_end - _rtc_data_start)
  101. : (_rtc_force_slow_end - _rtc_force_slow_start);
  102. _rtc_fast_length = (ORIGIN(rtc_slow_seg) == ORIGIN(rtc_data_location))
  103. ? (_rtc_force_fast_end - _rtc_fast_start)
  104. : (_rtc_noinit_end - _rtc_fast_start);
  105. ASSERT((_rtc_slow_length <= LENGTH(rtc_slow_seg)),
  106. "RTC_SLOW segment data does not fit.")
  107. ASSERT((_rtc_fast_length <= LENGTH(rtc_data_seg)),
  108. "RTC_FAST segment data does not fit.")
  109. .iram0.text :
  110. {
  111. _iram_start = ABSOLUTE(.);
  112. /* Vectors go to start of IRAM */
  113. ASSERT(ABSOLUTE(.) % 0x100 == 0, "vector address must be 256 byte aligned");
  114. KEEP(*(.exception_vectors.text));
  115. . = ALIGN(4);
  116. _invalid_pc_placeholder = ABSOLUTE(.);
  117. /* Code marked as running out of IRAM */
  118. _iram_text_start = ABSOLUTE(.);
  119. mapping[iram0_text]
  120. } > iram0_0_seg
  121. /**
  122. * This section is required to skip .iram0.text area because iram0_0_seg and
  123. * dram0_0_seg reflect the same address space on different buses.
  124. */
  125. .dram0.dummy (NOLOAD):
  126. {
  127. . = ORIGIN(dram0_0_seg) + _iram_end - _iram_start;
  128. } > dram0_0_seg
  129. .dram0.data :
  130. {
  131. _data_start = ABSOLUTE(.);
  132. *(.gnu.linkonce.d.*)
  133. *(.data1)
  134. __global_pointer$ = . + 0x800;
  135. *(.sdata)
  136. *(.sdata.*)
  137. *(.gnu.linkonce.s.*)
  138. *(.sdata2)
  139. *(.sdata2.*)
  140. *(.gnu.linkonce.s2.*)
  141. *(.jcr)
  142. _esp_system_init_fn_array_start = ABSOLUTE(.);
  143. KEEP (*(SORT(.esp_system_init_fn) SORT(.esp_system_init_fn.*)))
  144. _esp_system_init_fn_array_end = ABSOLUTE(.);
  145. mapping[dram0_data]
  146. _data_end = ABSOLUTE(.);
  147. . = ALIGN(4);
  148. } > dram0_0_seg
  149. /**
  150. * This section holds data that should not be initialized at power up.
  151. * The section located in Internal SRAM memory region. The macro _NOINIT
  152. * can be used as attribute to place data into this section.
  153. * See the "esp_attr.h" file for more information.
  154. */
  155. .noinit (NOLOAD):
  156. {
  157. . = ALIGN(4);
  158. _noinit_start = ABSOLUTE(.);
  159. *(.noinit .noinit.*)
  160. . = ALIGN(4) ;
  161. _noinit_end = ABSOLUTE(.);
  162. } > dram0_0_seg
  163. /* Shared RAM */
  164. .dram0.bss (NOLOAD) :
  165. {
  166. . = ALIGN (8);
  167. _bss_start = ABSOLUTE(.);
  168. mapping[dram0_bss]
  169. *(.dynsbss)
  170. *(.sbss)
  171. *(.sbss.*)
  172. *(.gnu.linkonce.sb.*)
  173. *(.scommon)
  174. *(.sbss2)
  175. *(.sbss2.*)
  176. *(.gnu.linkonce.sb2.*)
  177. *(.dynbss)
  178. *(.share.mem)
  179. *(.gnu.linkonce.b.*)
  180. . = ALIGN (8);
  181. _bss_end = ABSOLUTE(.);
  182. } > dram0_0_seg
  183. ASSERT(((_bss_end - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)), "DRAM segment data does not fit.")
  184. .flash.text :
  185. {
  186. _stext = .;
  187. _instruction_reserved_start = ABSOLUTE(.);
  188. _text_start = ABSOLUTE(.);
  189. mapping[flash_text]
  190. *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  191. *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */
  192. *(.fini.literal)
  193. *(.fini)
  194. *(.gnu.version)
  195. /** CPU will try to prefetch up to 16 bytes of
  196. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  197. * safe access to up to 16 bytes after the last real instruction, add
  198. * dummy bytes to ensure this
  199. */
  200. . += 16;
  201. _text_end = ABSOLUTE(.);
  202. _instruction_reserved_end = ABSOLUTE(.);
  203. _etext = .;
  204. /**
  205. * Similar to _iram_start, this symbol goes here so it is
  206. * resolved by addr2line in preference to the first symbol in
  207. * the flash.text segment.
  208. */
  209. _flash_cache_start = ABSOLUTE(0);
  210. } > default_code_seg
  211. /**
  212. * This dummy section represents the .flash.text section but in default_rodata_seg.
  213. * Thus, it must have its alignement and (at least) its size.
  214. */
  215. .flash_rodata_dummy (NOLOAD):
  216. {
  217. _flash_rodata_dummy_start = .;
  218. /* Start at the same alignement constraint than .flash.text */
  219. . = ALIGN(ALIGNOF(.flash.text));
  220. /* Create an empty gap as big as .flash.text section */
  221. . = . + SIZEOF(.flash.text);
  222. /* Prepare the alignement of the section above. Few bytes (0x20) must be
  223. * added for the mapping header. */
  224. . = ALIGN(0x10000) + 0x20;
  225. _rodata_reserved_start = .;
  226. } > default_rodata_seg
  227. .flash.appdesc : ALIGN(0x10)
  228. {
  229. _rodata_start = ABSOLUTE(.);
  230. *(.rodata_desc .rodata_desc.*) /* Should be the first. App version info. DO NOT PUT ANYTHING BEFORE IT! */
  231. *(.rodata_custom_desc .rodata_custom_desc.*) /* Should be the second. Custom app version info. DO NOT PUT ANYTHING BEFORE IT! */
  232. /* Create an empty gap within this section. Thanks to this, the end of this
  233. * section will match .flash.rodata's begin address. Thus, both sections
  234. * will be merged when creating the final bin image. */
  235. . = ALIGN(ALIGNOF(.flash.rodata));
  236. } >default_rodata_seg
  237. .flash.rodata : ALIGN(0x10)
  238. {
  239. _flash_rodata_start = ABSOLUTE(.);
  240. mapping[flash_rodata]
  241. *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
  242. *(.gnu.linkonce.r.*)
  243. *(.rodata1)
  244. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  245. *(.xt_except_table)
  246. *(.gcc_except_table .gcc_except_table.*)
  247. *(.gnu.linkonce.e.*)
  248. *(.gnu.version_r)
  249. . = (. + 7) & ~ 3;
  250. /*
  251. * C++ constructor and destructor tables
  252. * Don't include anything from crtbegin.o or crtend.o, as IDF doesn't use toolchain crt.
  253. *
  254. * RISC-V gcc is configured with --enable-initfini-array so it emits an .init_array section instead.
  255. * But the init_priority sections will be sorted for iteration in ascending order during startup.
  256. * The rest of the init_array sections is sorted for iteration in descending order during startup, however.
  257. * Hence a different section is generated for the init_priority functions which is iterated in
  258. * ascending order during startup. The corresponding code can be found in startup.c.
  259. */
  260. __init_priority_array_start = ABSOLUTE(.);
  261. KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array.*))
  262. __init_priority_array_end = ABSOLUTE(.);
  263. __init_array_start = ABSOLUTE(.);
  264. KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array))
  265. __init_array_end = ABSOLUTE(.);
  266. KEEP (*crtbegin.*(.dtors))
  267. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  268. KEEP (*(SORT(.dtors.*)))
  269. KEEP (*(.dtors))
  270. /* C++ exception handlers table: */
  271. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  272. *(.xt_except_desc)
  273. *(.gnu.linkonce.h.*)
  274. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  275. *(.xt_except_desc_end)
  276. *(.dynamic)
  277. *(.gnu.version_d)
  278. /* Addresses of memory regions reserved via SOC_RESERVE_MEMORY_REGION() */
  279. soc_reserved_memory_region_start = ABSOLUTE(.);
  280. KEEP (*(.reserved_memory_address))
  281. soc_reserved_memory_region_end = ABSOLUTE(.);
  282. _rodata_end = ABSOLUTE(.);
  283. /* Literals are also RO data. */
  284. _lit4_start = ABSOLUTE(.);
  285. *(*.lit4)
  286. *(.lit4.*)
  287. *(.gnu.linkonce.lit4.*)
  288. _lit4_end = ABSOLUTE(.);
  289. . = ALIGN(4);
  290. _thread_local_start = ABSOLUTE(.);
  291. *(.tdata)
  292. *(.tdata.*)
  293. *(.tbss)
  294. *(.tbss.*)
  295. *(.srodata)
  296. *(.srodata.*)
  297. _thread_local_end = ABSOLUTE(.);
  298. _rodata_reserved_end = ABSOLUTE(.);
  299. . = ALIGN(ALIGNOF(.eh_frame));
  300. } > default_rodata_seg
  301. /* Keep this section shall be at least aligned on 4 */
  302. .eh_frame : ALIGN(4)
  303. {
  304. __eh_frame = ABSOLUTE(.);
  305. KEEP (*(.eh_frame))
  306. __eh_frame_end = ABSOLUTE(.);
  307. /* Guarantee that this section and the next one will be merged by making
  308. * them adjacent. */
  309. . = ALIGN(ALIGNOF(.eh_frame_hdr));
  310. } > default_rodata_seg
  311. /* To avoid any exception in C++ exception frame unwinding code, this section
  312. * shall be aligned on 8. */
  313. .eh_frame_hdr : ALIGN(8)
  314. {
  315. __eh_frame_hdr = ABSOLUTE(.);
  316. KEEP (*(.eh_frame_hdr))
  317. __eh_frame_hdr_end = ABSOLUTE(.);
  318. } > default_rodata_seg
  319. /* Marks the end of IRAM code segment */
  320. .iram0.text_end (NOLOAD) :
  321. {
  322. /* ESP32-H2 memprot requires 16B padding for possible CPU prefetch and 512B alignment for PMS split lines */
  323. . += _esp_memprot_prefetch_pad_size;
  324. . = ALIGN(_esp_memprot_align_size);
  325. /* iram_end_test section exists for use by memprot unit tests only */
  326. *(.iram_end_test)
  327. _iram_text_end = ABSOLUTE(.);
  328. } > iram0_0_seg
  329. .iram0.data :
  330. {
  331. . = ALIGN(16);
  332. _iram_data_start = ABSOLUTE(.);
  333. mapping[iram0_data]
  334. _iram_data_end = ABSOLUTE(.);
  335. } > iram0_0_seg
  336. .iram0.bss (NOLOAD) :
  337. {
  338. . = ALIGN(16);
  339. _iram_bss_start = ABSOLUTE(.);
  340. mapping[iram0_bss]
  341. _iram_bss_end = ABSOLUTE(.);
  342. . = ALIGN(16);
  343. _iram_end = ABSOLUTE(.);
  344. } > iram0_0_seg
  345. /* Marks the end of data, bss and possibly rodata */
  346. .dram0.heap_start (NOLOAD) :
  347. {
  348. . = ALIGN (16);
  349. _heap_start = ABSOLUTE(.);
  350. } > dram0_0_seg
  351. }
  352. ASSERT(((_iram_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
  353. "IRAM0 segment data does not fit.")
  354. ASSERT(((_heap_start - ORIGIN(dram0_0_seg)) <= LENGTH(dram0_0_seg)),
  355. "DRAM segment data does not fit.")