sections.ld.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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, there are no iram0 data section to put
  154. * sections:iram_coredump entry defined in espcoredump's linker.lf file */
  155. _coredump_iram_start = 0;
  156. _coredump_iram_end = 0;
  157. /* align + add 16B for CPU dummy speculative instr. fetch */
  158. . = ALIGN(_esp_memprot_align_size) + _esp_memprot_prefetch_pad_size;
  159. /* iram_end_test section exists for use by memprot unit tests only */
  160. *(.iram_end_test)
  161. _iram_text_end = ABSOLUTE(.);
  162. _iram_end = ABSOLUTE(.);
  163. } > iram0_0_seg
  164. .dram0_reserved_for_iram (NOLOAD):
  165. {
  166. . = ORIGIN(dram0_0_seg) + _iram_end - _iram_start;
  167. } > dram0_0_seg
  168. .dram0.data :
  169. {
  170. _data_start = ABSOLUTE(.);
  171. *(.gnu.linkonce.d.*)
  172. *(.data1)
  173. *(.sdata)
  174. *(.sdata.*)
  175. *(.gnu.linkonce.s.*)
  176. *(.gnu.linkonce.s2.*)
  177. *(.jcr)
  178. mapping[dram0_data]
  179. _data_end = ABSOLUTE(.);
  180. . = ALIGN(4);
  181. } > dram0_0_seg
  182. /*This section holds data that should not be initialized at power up.
  183. The section located in Internal SRAM memory region. The macro _NOINIT
  184. can be used as attribute to place data into this section.
  185. See the esp_attr.h file for more information.
  186. */
  187. .noinit (NOLOAD):
  188. {
  189. . = ALIGN(4);
  190. _noinit_start = ABSOLUTE(.);
  191. *(.noinit .noinit.*)
  192. . = ALIGN(4) ;
  193. _noinit_end = ABSOLUTE(.);
  194. } > dram0_0_seg
  195. /* external memory bss, from any global variable with EXT_RAM_BSS_ATTR attribute*/
  196. .ext_ram.bss (NOLOAD) :
  197. {
  198. _ext_ram_bss_start = ABSOLUTE(.);
  199. mapping[extern_ram]
  200. . = ALIGN(4);
  201. _ext_ram_bss_end = ABSOLUTE(.);
  202. } > extern_ram_seg
  203. /* Shared RAM */
  204. .dram0.bss (NOLOAD) :
  205. {
  206. . = ALIGN (8);
  207. _bss_start = ABSOLUTE(.);
  208. mapping[dram0_bss]
  209. *(.dynsbss)
  210. *(.sbss)
  211. *(.sbss.*)
  212. *(.gnu.linkonce.sb.*)
  213. *(.scommon)
  214. *(.sbss2)
  215. *(.sbss2.*)
  216. *(.gnu.linkonce.sb2.*)
  217. *(.dynbss)
  218. *(.share.mem)
  219. *(.gnu.linkonce.b.*)
  220. . = ALIGN (8);
  221. _bss_end = ABSOLUTE(.);
  222. } > dram0_0_seg
  223. .flash.appdesc : ALIGN(0x10)
  224. {
  225. _rodata_reserved_start = ABSOLUTE(.);
  226. _rodata_start = ABSOLUTE(.);
  227. *(.rodata_desc .rodata_desc.*) /* Should be the first. App version info. DO NOT PUT ANYTHING BEFORE IT! */
  228. *(.rodata_custom_desc .rodata_custom_desc.*) /* Should be the second. Custom app version info. DO NOT PUT ANYTHING BEFORE IT! */
  229. /* Create an empty gap within this section. Thanks to this, the end of this
  230. * section will match .flah.rodata's begin address. Thus, both sections
  231. * will be merged when creating the final bin image. */
  232. . = ALIGN(ALIGNOF(.flash.rodata));
  233. } >default_rodata_seg
  234. .flash.rodata : ALIGN(0x10)
  235. {
  236. _flash_rodata_start = ABSOLUTE(.);
  237. mapping[flash_rodata]
  238. *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
  239. *(.gnu.linkonce.r.*)
  240. *(.rodata1)
  241. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  242. *(.xt_except_table)
  243. *(.gcc_except_table .gcc_except_table.*)
  244. *(.gnu.linkonce.e.*)
  245. *(.gnu.version_r)
  246. . = (. + 3) & ~ 3;
  247. __eh_frame = ABSOLUTE(.);
  248. KEEP(*(.eh_frame))
  249. . = (. + 7) & ~ 3;
  250. /* C++ constructor and destructor tables
  251. Make a point of not including anything from crtbegin.o or crtend.o, as IDF doesn't use toolchain crt
  252. */
  253. __init_array_start = ABSOLUTE(.);
  254. KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors SORT(.ctors.*)))
  255. __init_array_end = ABSOLUTE(.);
  256. KEEP (*crtbegin.*(.dtors))
  257. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  258. KEEP (*(SORT(.dtors.*)))
  259. KEEP (*(.dtors))
  260. /* C++ exception handlers table: */
  261. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  262. *(.xt_except_desc)
  263. *(.gnu.linkonce.h.*)
  264. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  265. *(.xt_except_desc_end)
  266. *(.dynamic)
  267. *(.gnu.version_d)
  268. /* Addresses of memory regions reserved via
  269. SOC_RESERVE_MEMORY_REGION() */
  270. soc_reserved_memory_region_start = ABSOLUTE(.);
  271. KEEP (*(.reserved_memory_address))
  272. soc_reserved_memory_region_end = ABSOLUTE(.);
  273. /* System init functions registered via ESP_SYSTEM_INIT_FN */
  274. _esp_system_init_fn_array_start = ABSOLUTE(.);
  275. KEEP (*(SORT_BY_INIT_PRIORITY(.esp_system_init_fn.*)))
  276. _esp_system_init_fn_array_end = ABSOLUTE(.);
  277. _rodata_end = ABSOLUTE(.);
  278. /* Literals are also RO data. */
  279. _lit4_start = ABSOLUTE(.);
  280. *(*.lit4)
  281. *(.lit4.*)
  282. *(.gnu.linkonce.lit4.*)
  283. _lit4_end = ABSOLUTE(.);
  284. . = ALIGN(4);
  285. _thread_local_start = ABSOLUTE(.);
  286. *(.tdata)
  287. *(.tdata.*)
  288. *(.tbss)
  289. *(.tbss.*)
  290. _thread_local_end = ABSOLUTE(.);
  291. _rodata_reserved_end = ABSOLUTE(.);
  292. . = ALIGN(4);
  293. } >default_rodata_seg
  294. _flash_rodata_align = ALIGNOF(.flash.rodata);
  295. .flash.rodata_noload (NOLOAD) :
  296. {
  297. . = ALIGN (4);
  298. mapping[rodata_noload]
  299. } > default_rodata_seg
  300. .flash.text :
  301. {
  302. _stext = .;
  303. _instruction_reserved_start = ABSOLUTE(.);
  304. _text_start = ABSOLUTE(.);
  305. mapping[flash_text]
  306. *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  307. *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */
  308. *(.fini.literal)
  309. *(.fini)
  310. *(.gnu.version)
  311. /** CPU will try to prefetch up to 16 bytes of
  312. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  313. * safe access to up to 16 bytes after the last real instruction, add
  314. * dummy bytes to ensure this
  315. */
  316. . += _esp_flash_mmap_prefetch_pad_size;
  317. _text_end = ABSOLUTE(.);
  318. _instruction_reserved_end = ABSOLUTE(.);
  319. _etext = .;
  320. /* Similar to _iram_start, this symbol goes here so it is
  321. resolved by addr2line in preference to the first symbol in
  322. the flash.text segment.
  323. */
  324. _flash_cache_start = ABSOLUTE(0);
  325. } >default_code_seg
  326. /* Marks the end of IRAM code segment */
  327. .iram0.text_end (NOLOAD) :
  328. {
  329. . = ALIGN (4);
  330. _iram_end = ABSOLUTE(.);
  331. } > iram0_0_seg
  332. /* Marks the end of data, bss and possibly rodata */
  333. .dram0.heap_start (NOLOAD) :
  334. {
  335. . = ALIGN (8);
  336. _heap_start = ABSOLUTE(.);
  337. } > dram0_0_seg
  338. /** This section will be used by the debugger and disassembler to get more information
  339. * about raw data present in the code.
  340. * Indeed, it may be required to add some padding at some points in the code
  341. * in order to align a branch/jump destination on a particular bound.
  342. * Padding these instructions will generate null bytes that shall be
  343. * interpreted as data, and not code by the debugger or disassembler.
  344. * This section will only be present in the ELF file, not in the final binary
  345. * For more details, check GCC-212
  346. */
  347. .xt.prop 0 :
  348. {
  349. KEEP (*(.xt.prop .gnu.linkonce.prop.*))
  350. }
  351. .xt.lit 0 :
  352. {
  353. KEEP (*(.xt.lit .gnu.linkonce.p.*))
  354. }
  355. }
  356. ASSERT(((_iram_text_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
  357. "IRAM0 segment data does not fit.")
  358. ASSERT(((_heap_start - _data_start) <= LENGTH(dram0_0_seg)),
  359. "DRAM segment data does not fit.")