bootloader.ld 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 = 0x4004B000, len = 0x4000 /* SRAM part of block 12 and 13 */
  12. iram_loader_seg (RWX) : org = 0x4004F000, len = 0x7000 /* SRAM part of block 13, 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. /* we use either libgcc or compiler-rt, so put similar entries for them here */
  27. *libgcc.a:(.literal .text .literal.* .text.*)
  28. *libclang_rt.builtins.a:(.literal .text .literal.* .text.*)
  29. *libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
  30. *libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
  31. *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
  32. *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
  33. *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
  34. *libesp_common.a:fpga_overrides.*(.literal.bootloader_fill_random .text.bootloader_fill_random)
  35. *libbootloader_support.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
  36. *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
  37. *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
  38. *libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
  39. *libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
  40. *libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
  41. *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
  42. *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
  43. *libbootloader_support.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*)
  44. *libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
  45. *libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
  46. *libbootloader_support.a:secure_boot_secure_features.*(.literal .text .literal.* .text.*)
  47. *libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*)
  48. *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
  49. *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
  50. *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
  51. *libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
  52. *libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
  53. *libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
  54. *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
  55. *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
  56. *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
  57. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  58. *libesp_rom.a:esp_rom_regi2c.*(.literal .text .literal.* .text.*)
  59. *(.fini.literal)
  60. *(.fini)
  61. *(.gnu.version)
  62. _loader_text_end = ABSOLUTE(.);
  63. } > iram_loader_seg
  64. .iram.text :
  65. {
  66. . = ALIGN (16);
  67. *(.entry.text)
  68. *(.init.literal)
  69. *(.init)
  70. } > iram_seg
  71. /* Shared RAM */
  72. .dram0.bss (NOLOAD) :
  73. {
  74. . = ALIGN (8);
  75. _dram_start = ABSOLUTE(.);
  76. _bss_start = ABSOLUTE(.);
  77. *(.dynsbss)
  78. *(.sbss)
  79. *(.sbss.*)
  80. *(.gnu.linkonce.sb.*)
  81. *(.scommon)
  82. *(.sbss2)
  83. *(.sbss2.*)
  84. *(.gnu.linkonce.sb2.*)
  85. *(.dynbss)
  86. *(.bss)
  87. *(.bss.*)
  88. *(.gnu.linkonce.b.*)
  89. *(COMMON)
  90. . = ALIGN (8);
  91. _bss_end = ABSOLUTE(.);
  92. } >dram_seg
  93. .dram0.bootdesc : ALIGN(0x10)
  94. {
  95. _data_start = ABSOLUTE(.);
  96. *(.data_bootloader_desc .data_bootloader_desc.*) /* Should be the first. Bootloader version info. DO NOT PUT ANYTHING BEFORE IT! */
  97. } > dram_seg
  98. .dram0.data :
  99. {
  100. *(.data)
  101. *(.data.*)
  102. *(.gnu.linkonce.d.*)
  103. *(.data1)
  104. *(.sdata)
  105. *(.sdata.*)
  106. *(.gnu.linkonce.s.*)
  107. *(.gnu.linkonce.s2.*)
  108. *(.jcr)
  109. _data_end = ABSOLUTE(.);
  110. } >dram_seg
  111. .dram0.rodata :
  112. {
  113. _rodata_start = ABSOLUTE(.);
  114. *(.rodata)
  115. *(.rodata.*)
  116. *(.gnu.linkonce.r.*)
  117. *(.rodata1)
  118. *(.sdata2 .sdata2.*)
  119. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  120. *(.xt_except_table)
  121. *(.gcc_except_table)
  122. *(.gnu.linkonce.e.*)
  123. *(.gnu.version_r)
  124. *(.eh_frame)
  125. . = (. + 3) & ~ 3;
  126. /* C++ constructor and destructor tables, properly ordered: */
  127. __init_array_start = ABSOLUTE(.);
  128. KEEP (*crtbegin.*(.ctors))
  129. KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
  130. KEEP (*(SORT(.ctors.*)))
  131. KEEP (*(.ctors))
  132. __init_array_end = ABSOLUTE(.);
  133. KEEP (*crtbegin.*(.dtors))
  134. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  135. KEEP (*(SORT(.dtors.*)))
  136. KEEP (*(.dtors))
  137. /* C++ exception handlers table: */
  138. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  139. *(.xt_except_desc)
  140. *(.gnu.linkonce.h.*)
  141. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  142. *(.xt_except_desc_end)
  143. *(.dynamic)
  144. *(.gnu.version_d)
  145. _rodata_end = ABSOLUTE(.);
  146. /* Literals are also RO data. */
  147. _lit4_start = ABSOLUTE(.);
  148. *(*.lit4)
  149. *(.lit4.*)
  150. *(.gnu.linkonce.lit4.*)
  151. _lit4_end = ABSOLUTE(.);
  152. . = ALIGN(4);
  153. _dram_end = ABSOLUTE(.);
  154. } >dram_seg
  155. .iram.text :
  156. {
  157. _stext = .;
  158. _text_start = ABSOLUTE(.);
  159. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  160. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  161. *(.fini.literal)
  162. *(.fini)
  163. *(.gnu.version)
  164. /** CPU will try to prefetch up to 16 bytes of
  165. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  166. * safe access to up to 16 bytes after the last real instruction, add
  167. * dummy bytes to ensure this
  168. */
  169. . += 16;
  170. _text_end = ABSOLUTE(.);
  171. _etext = .;
  172. } > iram_seg
  173. /** This section will be used by the debugger and disassembler to get more information
  174. * about raw data present in the code.
  175. * Indeed, it may be required to add some padding at some points in the code
  176. * in order to align a branch/jump destination on a particular bound.
  177. * Padding these instructions will generate null bytes that shall be
  178. * interpreted as data, and not code by the debugger or disassembler.
  179. * This section will only be present in the ELF file, not in the final binary
  180. * For more details, check GCC-212
  181. */
  182. .xt.prop 0 :
  183. {
  184. KEEP (*(.xt.prop .gnu.linkonce.prop.*))
  185. }
  186. .xt.lit 0 :
  187. {
  188. KEEP (*(.xt.lit .gnu.linkonce.p.*))
  189. }
  190. }