sections.ld.in 11 KB

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