bootloader.ld 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /*
  7. Linker file used to link the bootloader.
  8. */
  9. /* Simplified memory map for the bootloader
  10. The main purpose is to make sure the bootloader can load into main memory
  11. without overwriting itself.
  12. */
  13. MEMORY
  14. {
  15. /* IRAM POOL1, used for APP CPU cache. Bootloader runs from here during the final stage of loading the app because APP CPU is still held in reset, the main app enables APP CPU cache */
  16. iram_loader_seg (RWX) : org = 0x40078000, len = 0x8000 /* 32KB, APP CPU cache */
  17. /* 63kB, IRAM. We skip the first 1k to prevent the entry point being
  18. placed into the same range as exception vectors in the app.
  19. This leads to idf_monitor decoding ROM bootloader "entry 0x40080xxx"
  20. message as one of the exception vectors, which looks scary to users.
  21. */
  22. iram_seg (RWX) : org = 0x40080400, len = 0xfc00
  23. /* 64k at the end of DRAM, after ROM bootloader stack */
  24. dram_seg (RW) : org = 0x3FFF0000, len = 0x10000
  25. }
  26. /* Default entry point: */
  27. ENTRY(call_start_cpu0);
  28. SECTIONS
  29. {
  30. .iram_loader.text :
  31. {
  32. . = ALIGN (16);
  33. _loader_text_start = ABSOLUTE(.);
  34. *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  35. *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
  36. *liblog.a:(.literal .text .literal.* .text.*)
  37. *libgcc.a:(.literal .text .literal.* .text.*)
  38. *libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
  39. *libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
  40. *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
  41. *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
  42. *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
  43. *libesp_common.a:fpga_overrides.*(.literal.bootloader_fill_random .text.bootloader_fill_random)
  44. *libbootloader_support.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
  45. *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
  46. *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
  47. *libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
  48. *libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
  49. *libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
  50. *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
  51. *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
  52. *libbootloader_support.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*)
  53. *libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
  54. *libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
  55. *libbootloader_support.a:secure_boot_secure_features.*(.literal .text .literal.* .text.*)
  56. *libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*)
  57. *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
  58. *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
  59. *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
  60. *libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
  61. *libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
  62. *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
  63. *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
  64. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  65. *libesp_rom.a:*.*(.literal .text .literal.* .text.*)
  66. *(.fini.literal)
  67. *(.fini)
  68. *(.gnu.version)
  69. _loader_text_end = ABSOLUTE(.);
  70. } > iram_loader_seg
  71. .iram.text :
  72. {
  73. . = ALIGN (16);
  74. *(.entry.text)
  75. *(.init.literal)
  76. *(.init)
  77. } > iram_seg
  78. /* Shared RAM */
  79. .dram0.bss (NOLOAD) :
  80. {
  81. . = ALIGN (8);
  82. _dram_start = ABSOLUTE(.);
  83. _bss_start = ABSOLUTE(.);
  84. *(.dynsbss)
  85. *(.sbss)
  86. *(.sbss.*)
  87. *(.gnu.linkonce.sb.*)
  88. *(.scommon)
  89. *(.sbss2)
  90. *(.sbss2.*)
  91. *(.gnu.linkonce.sb2.*)
  92. *(.dynbss)
  93. *(.bss)
  94. *(.bss.*)
  95. *(.gnu.linkonce.b.*)
  96. *(COMMON)
  97. . = ALIGN (8);
  98. _bss_end = ABSOLUTE(.);
  99. } >dram_seg
  100. .dram0.data :
  101. {
  102. _data_start = ABSOLUTE(.);
  103. *(.data)
  104. *(.data.*)
  105. *(.gnu.linkonce.d.*)
  106. *(.data1)
  107. *(.sdata)
  108. *(.sdata.*)
  109. *(.gnu.linkonce.s.*)
  110. *(.sdata2)
  111. *(.sdata2.*)
  112. *(.gnu.linkonce.s2.*)
  113. *(.jcr)
  114. _data_end = ABSOLUTE(.);
  115. } >dram_seg
  116. .dram0.rodata :
  117. {
  118. _rodata_start = ABSOLUTE(.);
  119. *(.rodata)
  120. *(.rodata.*)
  121. *(.gnu.linkonce.r.*)
  122. *(.rodata1)
  123. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  124. *(.xt_except_table)
  125. *(.gcc_except_table)
  126. *(.gnu.linkonce.e.*)
  127. *(.gnu.version_r)
  128. *(.eh_frame)
  129. . = (. + 3) & ~ 3;
  130. /* C++ constructor and destructor tables, properly ordered: */
  131. __init_array_start = ABSOLUTE(.);
  132. KEEP (*crtbegin.*(.ctors))
  133. KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
  134. KEEP (*(SORT(.ctors.*)))
  135. KEEP (*(.ctors))
  136. __init_array_end = ABSOLUTE(.);
  137. KEEP (*crtbegin.*(.dtors))
  138. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  139. KEEP (*(SORT(.dtors.*)))
  140. KEEP (*(.dtors))
  141. /* C++ exception handlers table: */
  142. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  143. *(.xt_except_desc)
  144. *(.gnu.linkonce.h.*)
  145. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  146. *(.xt_except_desc_end)
  147. *(.dynamic)
  148. *(.gnu.version_d)
  149. _rodata_end = ABSOLUTE(.);
  150. /* Literals are also RO data. */
  151. _lit4_start = ABSOLUTE(.);
  152. *(*.lit4)
  153. *(.lit4.*)
  154. *(.gnu.linkonce.lit4.*)
  155. _lit4_end = ABSOLUTE(.);
  156. . = ALIGN(4);
  157. _dram_end = ABSOLUTE(.);
  158. } >dram_seg
  159. .iram.text :
  160. {
  161. _stext = .;
  162. _text_start = ABSOLUTE(.);
  163. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  164. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  165. *(.fini.literal)
  166. *(.fini)
  167. *(.gnu.version)
  168. /** CPU will try to prefetch up to 16 bytes of
  169. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  170. * safe access to up to 16 bytes after the last real instruction, add
  171. * dummy bytes to ensure this
  172. */
  173. . += 16;
  174. _text_end = ABSOLUTE(.);
  175. _etext = .;
  176. } > iram_seg
  177. }