sections.ld.in 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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.*)
  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. /**
  100. * This section holds RTC data that should have fixed addresses.
  101. * The data are not initialized at power-up and are retained during deep sleep.
  102. */
  103. .rtc_reserved (NOLOAD):
  104. {
  105. . = ALIGN(4);
  106. _rtc_reserved_start = ABSOLUTE(.);
  107. /* New data can only be added here to ensure existing data are not moved.
  108. Because data have adhered to the end of the segment and code is relied on it.
  109. >> put new data here << */
  110. *(.rtc_timer_data_in_rtc_mem .rtc_timer_data_in_rtc_mem.*)
  111. KEEP(*(.bootloader_data_rtc_mem .bootloader_data_rtc_mem.*))
  112. _rtc_reserved_end = ABSOLUTE(.);
  113. } > rtc_reserved_seg
  114. _rtc_reserved_length = _rtc_reserved_end - _rtc_reserved_start;
  115. ASSERT((_rtc_reserved_length <= LENGTH(rtc_reserved_seg)),
  116. "RTC reserved segment data does not fit.")
  117. /* Get size of rtc slow data based on rtc_data_location alias */
  118. _rtc_slow_length = (ORIGIN(rtc_slow_seg) == ORIGIN(rtc_data_location))
  119. ? (_rtc_force_slow_end - _rtc_data_start)
  120. : (_rtc_force_slow_end - _rtc_force_slow_start);
  121. _rtc_fast_length = (ORIGIN(rtc_slow_seg) == ORIGIN(rtc_data_location))
  122. ? (_rtc_force_fast_end - _rtc_fast_start)
  123. : (_rtc_noinit_end - _rtc_fast_start);
  124. ASSERT((_rtc_slow_length <= LENGTH(rtc_slow_seg)),
  125. "RTC_SLOW segment data does not fit.")
  126. ASSERT((_rtc_fast_length <= LENGTH(rtc_data_seg)),
  127. "RTC_FAST segment data does not fit.")
  128. /* Send .iram0 code to iram */
  129. .iram0.vectors :
  130. {
  131. _iram_start = ABSOLUTE(.);
  132. /* Vectors go to IRAM */
  133. _vector_table = ABSOLUTE(.);
  134. /* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */
  135. . = 0x0;
  136. KEEP(*(.WindowVectors.text));
  137. . = 0x180;
  138. KEEP(*(.Level2InterruptVector.text));
  139. . = 0x1c0;
  140. KEEP(*(.Level3InterruptVector.text));
  141. . = 0x200;
  142. KEEP(*(.Level4InterruptVector.text));
  143. . = 0x240;
  144. KEEP(*(.Level5InterruptVector.text));
  145. . = 0x280;
  146. KEEP(*(.DebugExceptionVector.text));
  147. . = 0x2c0;
  148. KEEP(*(.NMIExceptionVector.text));
  149. . = 0x300;
  150. KEEP(*(.KernelExceptionVector.text));
  151. . = 0x340;
  152. KEEP(*(.UserExceptionVector.text));
  153. . = 0x3C0;
  154. KEEP(*(.DoubleExceptionVector.text));
  155. . = 0x400;
  156. _invalid_pc_placeholder = ABSOLUTE(.);
  157. *(.*Vector.literal)
  158. *(.UserEnter.literal);
  159. *(.UserEnter.text);
  160. . = ALIGN (16);
  161. *(.entry.text)
  162. *(.init.literal)
  163. *(.init)
  164. _init_end = ABSOLUTE(.);
  165. } > iram0_0_seg
  166. .iram0.text :
  167. {
  168. /* Code marked as runnning out of IRAM */
  169. _iram_text_start = ABSOLUTE(.);
  170. mapping[iram0_text]
  171. /* Added to maintain compability, there are no iram0 data section to put
  172. * sections:iram_coredump entry defined in espcoredump's linker.lf file */
  173. _coredump_iram_start = 0;
  174. _coredump_iram_end = 0;
  175. /* align + add 16B for CPU dummy speculative instr. fetch */
  176. . = ALIGN(_esp_memprot_align_size) + _esp_memprot_prefetch_pad_size;
  177. /* iram_end_test section exists for use by memprot unit tests only */
  178. *(.iram_end_test)
  179. _iram_text_end = ABSOLUTE(.);
  180. } > iram0_0_seg
  181. .dram0_reserved_for_iram (NOLOAD):
  182. {
  183. . = ORIGIN(dram0_0_seg) + _iram_end - _iram_start;
  184. } > dram0_0_seg
  185. .dram0.data :
  186. {
  187. _data_start = ABSOLUTE(.);
  188. *(.gnu.linkonce.d.*)
  189. *(.data1)
  190. *(.sdata)
  191. *(.sdata.*)
  192. *(.gnu.linkonce.s.*)
  193. *(.gnu.linkonce.s2.*)
  194. *(.jcr)
  195. mapping[dram0_data]
  196. _data_end = ABSOLUTE(.);
  197. . = ALIGN(4);
  198. } > dram0_0_seg
  199. /*This section holds data that should not be initialized at power up.
  200. The section located in Internal SRAM memory region. The macro _NOINIT
  201. can be used as attribute to place data into this section.
  202. See the esp_attr.h file for more information.
  203. */
  204. .noinit (NOLOAD):
  205. {
  206. . = ALIGN(4);
  207. _noinit_start = ABSOLUTE(.);
  208. *(.noinit .noinit.*)
  209. . = ALIGN(4) ;
  210. _noinit_end = ABSOLUTE(.);
  211. } > dram0_0_seg
  212. /* external memory bss, from any global variable with EXT_RAM_BSS_ATTR attribute*/
  213. .ext_ram.bss (NOLOAD) :
  214. {
  215. _ext_ram_bss_start = ABSOLUTE(.);
  216. mapping[extern_ram]
  217. . = ALIGN(4);
  218. _ext_ram_bss_end = ABSOLUTE(.);
  219. } > extern_ram_seg
  220. /* Shared RAM */
  221. .dram0.bss (NOLOAD) :
  222. {
  223. . = ALIGN (8);
  224. _bss_start = ABSOLUTE(.);
  225. mapping[dram0_bss]
  226. *(.dynsbss)
  227. *(.sbss)
  228. *(.sbss.*)
  229. *(.gnu.linkonce.sb.*)
  230. *(.scommon)
  231. *(.sbss2)
  232. *(.sbss2.*)
  233. *(.gnu.linkonce.sb2.*)
  234. *(.dynbss)
  235. *(.share.mem)
  236. *(.gnu.linkonce.b.*)
  237. . = ALIGN (8);
  238. _bss_end = ABSOLUTE(.);
  239. } > dram0_0_seg
  240. .flash.appdesc : ALIGN(0x10)
  241. {
  242. _rodata_reserved_start = ABSOLUTE(.); /* This is a symbol marking the flash.rodata start, this can be used for mmu driver to maintain virtual address */
  243. _rodata_start = ABSOLUTE(.);
  244. *(.rodata_desc .rodata_desc.*) /* Should be the first. App version info. DO NOT PUT ANYTHING BEFORE IT! */
  245. *(.rodata_custom_desc .rodata_custom_desc.*) /* Should be the second. Custom app version info. DO NOT PUT ANYTHING BEFORE IT! */
  246. /* Create an empty gap within this section. Thanks to this, the end of this
  247. * section will match .flah.rodata's begin address. Thus, both sections
  248. * will be merged when creating the final bin image. */
  249. . = ALIGN(ALIGNOF(.flash.rodata));
  250. } >default_rodata_seg
  251. .flash.rodata : ALIGN(0x10)
  252. {
  253. _flash_rodata_start = ABSOLUTE(.);
  254. mapping[flash_rodata]
  255. *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */
  256. *(.gnu.linkonce.r.*)
  257. *(.rodata1)
  258. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  259. *(.xt_except_table)
  260. *(.gcc_except_table .gcc_except_table.*)
  261. *(.gnu.linkonce.e.*)
  262. *(.gnu.version_r)
  263. . = (. + 3) & ~ 3;
  264. __eh_frame = ABSOLUTE(.);
  265. KEEP(*(.eh_frame))
  266. . = (. + 7) & ~ 3;
  267. /* C++ constructor and destructor tables
  268. Make a point of not including anything from crtbegin.o or crtend.o, as IDF doesn't use toolchain crt
  269. */
  270. __init_array_start = ABSOLUTE(.);
  271. KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors SORT(.ctors.*)))
  272. __init_array_end = ABSOLUTE(.);
  273. KEEP (*crtbegin.*(.dtors))
  274. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  275. KEEP (*(SORT(.dtors.*)))
  276. KEEP (*(.dtors))
  277. /* C++ exception handlers table: */
  278. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  279. *(.xt_except_desc)
  280. *(.gnu.linkonce.h.*)
  281. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  282. *(.xt_except_desc_end)
  283. *(.dynamic)
  284. *(.gnu.version_d)
  285. /* Addresses of memory regions reserved via
  286. SOC_RESERVE_MEMORY_REGION() */
  287. soc_reserved_memory_region_start = ABSOLUTE(.);
  288. KEEP (*(.reserved_memory_address))
  289. soc_reserved_memory_region_end = ABSOLUTE(.);
  290. /* System init functions registered via ESP_SYSTEM_INIT_FN */
  291. _esp_system_init_fn_array_start = ABSOLUTE(.);
  292. KEEP (*(SORT_BY_INIT_PRIORITY(.esp_system_init_fn.*)))
  293. _esp_system_init_fn_array_end = ABSOLUTE(.);
  294. _rodata_end = ABSOLUTE(.);
  295. /* Literals are also RO data. */
  296. _lit4_start = ABSOLUTE(.);
  297. *(*.lit4)
  298. *(.lit4.*)
  299. *(.gnu.linkonce.lit4.*)
  300. _lit4_end = ABSOLUTE(.);
  301. . = ALIGN(4);
  302. _thread_local_start = ABSOLUTE(.);
  303. *(.tdata)
  304. *(.tdata.*)
  305. *(.tbss)
  306. *(.tbss.*)
  307. _thread_local_end = ABSOLUTE(.);
  308. . = ALIGN(4);
  309. } >default_rodata_seg
  310. _flash_rodata_align = ALIGNOF(.flash.rodata);
  311. /*
  312. This section is a place where we dump all the rodata which aren't used at runtime,
  313. so as to avoid binary size increase
  314. */
  315. .flash.rodata_noload (NOLOAD) :
  316. {
  317. /*
  318. This is a symbol marking the flash.rodata end, this can be used for mmu driver to maintain virtual address
  319. We don't need to include the noload rodata in this section
  320. */
  321. _rodata_reserved_end = ABSOLUTE(.);
  322. . = ALIGN (4);
  323. mapping[rodata_noload]
  324. } > default_rodata_seg
  325. .flash.text :
  326. {
  327. _stext = .;
  328. _instruction_reserved_start = ABSOLUTE(.); /* This is a symbol marking the flash.text start, this can be used for mmu driver to maintain virtual address */
  329. _text_start = ABSOLUTE(.);
  330. mapping[flash_text]
  331. *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  332. *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */
  333. *(.fini.literal)
  334. *(.fini)
  335. *(.gnu.version)
  336. /** CPU will try to prefetch up to 16 bytes of
  337. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  338. * safe access to up to 16 bytes after the last real instruction, add
  339. * dummy bytes to ensure this
  340. */
  341. . += _esp_flash_mmap_prefetch_pad_size;
  342. _text_end = ABSOLUTE(.);
  343. _instruction_reserved_end = ABSOLUTE(.); /* This is a symbol marking the flash.text end, this can be used for mmu driver to maintain virtual address */
  344. _etext = .;
  345. /* Similar to _iram_start, this symbol goes here so it is
  346. resolved by addr2line in preference to the first symbol in
  347. the flash.text segment.
  348. */
  349. _flash_cache_start = ABSOLUTE(0);
  350. } >default_code_seg
  351. /* Marks the end of IRAM code segment */
  352. .iram0.text_end (NOLOAD) :
  353. {
  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. /* Lowest possible start address for the heap */
  362. _heap_low_start = ABSOLUTE(.);
  363. } > dram0_0_seg
  364. /** This section will be used by the debugger and disassembler to get more information
  365. * about raw data present in the code.
  366. * Indeed, it may be required to add some padding at some points in the code
  367. * in order to align a branch/jump destination on a particular bound.
  368. * Padding these instructions will generate null bytes that shall be
  369. * interpreted as data, and not code by the debugger or disassembler.
  370. * This section will only be present in the ELF file, not in the final binary
  371. * For more details, check GCC-212
  372. */
  373. .xt.prop 0 :
  374. {
  375. KEEP (*(.xt.prop .gnu.linkonce.prop.*))
  376. }
  377. .xt.lit 0 :
  378. {
  379. KEEP (*(.xt.lit .gnu.linkonce.p.*))
  380. }
  381. }
  382. ASSERT(((_iram_text_end - ORIGIN(iram0_0_seg)) <= LENGTH(iram0_0_seg)),
  383. "IRAM0 segment data does not fit.")
  384. ASSERT(((_heap_low_start - _data_start) <= LENGTH(dram0_0_seg)),
  385. "DRAM segment data does not fit.")