sections.ld.in 11 KB

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