sections.ld.in 11 KB

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