sections.ld.in 14 KB

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