bootloader.ld 6.0 KB

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