sections.ld.in 12 KB

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