esp32.bootloader.ld 5.2 KB

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