esp32s2.project.ld.in 9.6 KB

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