bootloader.ld 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /* Simplified memory map for the bootloader.
  7. * Make sure the bootloader can load into main memory without overwriting itself.
  8. */
  9. MEMORY
  10. {
  11. iram_seg (RWX) : org = 0x4004c000, len = 0x4000 /* SRAM Block 13 */
  12. iram_loader_seg (RWX) : org = 0x40050000, len = 0x6000 /* SRAM Block 14 & part of 15 */
  13. dram_seg (RW) : org = 0x3FFE6000, len = 0x4B00 /* Part SRAM Blocks 15 & 16, ROM static buffer starts at end of this region (reclaimed after app runs) */
  14. }
  15. /* Default entry point: */
  16. ENTRY(call_start_cpu0);
  17. SECTIONS
  18. {
  19. .iram_loader.text :
  20. {
  21. . = ALIGN (16);
  22. _loader_text_start = ABSOLUTE(.);
  23. *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  24. *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
  25. *liblog.a:(.literal .text .literal.* .text.*)
  26. *libgcc.a:(.literal .text .literal.* .text.*)
  27. *libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
  28. *libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
  29. *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
  30. *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
  31. *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
  32. *libesp_common.a:fpga_overrides.*(.literal.bootloader_fill_random .text.bootloader_fill_random)
  33. *libbootloader_support.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
  34. *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
  35. *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
  36. *libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
  37. *libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
  38. *libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
  39. *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
  40. *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
  41. *libbootloader_support.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*)
  42. *libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
  43. *libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
  44. *libbootloader_support.a:secure_boot_secure_features.*(.literal .text .literal.* .text.*)
  45. *libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*)
  46. *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
  47. *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
  48. *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
  49. *libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
  50. *libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
  51. *libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
  52. *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
  53. *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
  54. *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
  55. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  56. *libesp_rom.a:esp_rom_regi2c.*(.literal .text .literal.* .text.*)
  57. *(.fini.literal)
  58. *(.fini)
  59. *(.gnu.version)
  60. _loader_text_end = ABSOLUTE(.);
  61. } > iram_loader_seg
  62. .iram.text :
  63. {
  64. . = ALIGN (16);
  65. *(.entry.text)
  66. *(.init.literal)
  67. *(.init)
  68. } > iram_seg
  69. /* Shared RAM */
  70. .dram0.bss (NOLOAD) :
  71. {
  72. . = ALIGN (8);
  73. _dram_start = ABSOLUTE(.);
  74. _bss_start = ABSOLUTE(.);
  75. *(.dynsbss)
  76. *(.sbss)
  77. *(.sbss.*)
  78. *(.gnu.linkonce.sb.*)
  79. *(.scommon)
  80. *(.sbss2)
  81. *(.sbss2.*)
  82. *(.gnu.linkonce.sb2.*)
  83. *(.dynbss)
  84. *(.bss)
  85. *(.bss.*)
  86. *(.gnu.linkonce.b.*)
  87. *(COMMON)
  88. . = ALIGN (8);
  89. _bss_end = ABSOLUTE(.);
  90. } >dram_seg
  91. .dram0.data :
  92. {
  93. _data_start = ABSOLUTE(.);
  94. *(.data)
  95. *(.data.*)
  96. *(.gnu.linkonce.d.*)
  97. *(.data1)
  98. *(.sdata)
  99. *(.sdata.*)
  100. *(.gnu.linkonce.s.*)
  101. *(.gnu.linkonce.s2.*)
  102. *(.jcr)
  103. _data_end = ABSOLUTE(.);
  104. } >dram_seg
  105. .dram0.rodata :
  106. {
  107. _rodata_start = ABSOLUTE(.);
  108. *(.rodata)
  109. *(.rodata.*)
  110. *(.gnu.linkonce.r.*)
  111. *(.rodata1)
  112. *(.sdata2 .sdata2.*)
  113. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  114. *(.xt_except_table)
  115. *(.gcc_except_table)
  116. *(.gnu.linkonce.e.*)
  117. *(.gnu.version_r)
  118. *(.eh_frame)
  119. . = (. + 3) & ~ 3;
  120. /* C++ constructor and destructor tables, properly ordered: */
  121. __init_array_start = ABSOLUTE(.);
  122. KEEP (*crtbegin.*(.ctors))
  123. KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
  124. KEEP (*(SORT(.ctors.*)))
  125. KEEP (*(.ctors))
  126. __init_array_end = ABSOLUTE(.);
  127. KEEP (*crtbegin.*(.dtors))
  128. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  129. KEEP (*(SORT(.dtors.*)))
  130. KEEP (*(.dtors))
  131. /* C++ exception handlers table: */
  132. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  133. *(.xt_except_desc)
  134. *(.gnu.linkonce.h.*)
  135. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  136. *(.xt_except_desc_end)
  137. *(.dynamic)
  138. *(.gnu.version_d)
  139. _rodata_end = ABSOLUTE(.);
  140. /* Literals are also RO data. */
  141. _lit4_start = ABSOLUTE(.);
  142. *(*.lit4)
  143. *(.lit4.*)
  144. *(.gnu.linkonce.lit4.*)
  145. _lit4_end = ABSOLUTE(.);
  146. . = ALIGN(4);
  147. _dram_end = ABSOLUTE(.);
  148. } >dram_seg
  149. .iram.text :
  150. {
  151. _stext = .;
  152. _text_start = ABSOLUTE(.);
  153. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  154. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  155. *(.fini.literal)
  156. *(.fini)
  157. *(.gnu.version)
  158. /** CPU will try to prefetch up to 16 bytes of
  159. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  160. * safe access to up to 16 bytes after the last real instruction, add
  161. * dummy bytes to ensure this
  162. */
  163. . += 16;
  164. _text_end = ABSOLUTE(.);
  165. _etext = .;
  166. } > iram_seg
  167. /** This section will be used by the debugger and disassembler to get more information
  168. * about raw data present in the code.
  169. * Indeed, it may be required to add some padding at some points in the code
  170. * in order to align a branch/jump destination on a particular bound.
  171. * Padding these instructions will generate null bytes that shall be
  172. * interpreted as data, and not code by the debugger or disassembler.
  173. * This section will only be present in the ELF file, not in the final binary
  174. * For more details, check GCC-212
  175. */
  176. .xt.prop 0 :
  177. {
  178. KEEP (*(.xt.prop .gnu.linkonce.prop.*))
  179. }
  180. .xt.lit 0 :
  181. {
  182. KEEP (*(.xt.lit .gnu.linkonce.p.*))
  183. }
  184. }