esp32.bootloader.ld 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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_common.*(.literal .text .literal.* .text.*)
  36. *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
  37. *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
  38. *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
  39. *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
  40. *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
  41. *libbootloader_support.a:flash_encrypt.*(.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_signatures.*(.literal .text .literal.* .text.*)
  45. *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
  46. *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
  47. *libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
  48. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  49. *(.fini.literal)
  50. *(.fini)
  51. *(.gnu.version)
  52. _loader_text_end = ABSOLUTE(.);
  53. } > iram_loader_seg
  54. .iram.text :
  55. {
  56. . = ALIGN (16);
  57. *(.entry.text)
  58. *(.init.literal)
  59. *(.init)
  60. } > iram_seg
  61. /* Shared RAM */
  62. .dram0.bss (NOLOAD) :
  63. {
  64. . = ALIGN (8);
  65. _bss_start = ABSOLUTE(.);
  66. *(.dynsbss)
  67. *(.sbss)
  68. *(.sbss.*)
  69. *(.gnu.linkonce.sb.*)
  70. *(.scommon)
  71. *(.sbss2)
  72. *(.sbss2.*)
  73. *(.gnu.linkonce.sb2.*)
  74. *(.dynbss)
  75. *(.bss)
  76. *(.bss.*)
  77. *(.gnu.linkonce.b.*)
  78. *(COMMON)
  79. . = ALIGN (8);
  80. _bss_end = ABSOLUTE(.);
  81. } >dram_seg
  82. .dram0.data :
  83. {
  84. _data_start = ABSOLUTE(.);
  85. *(.data)
  86. *(.data.*)
  87. *(.gnu.linkonce.d.*)
  88. *(.data1)
  89. *(.sdata)
  90. *(.sdata.*)
  91. *(.gnu.linkonce.s.*)
  92. *(.sdata2)
  93. *(.sdata2.*)
  94. *(.gnu.linkonce.s2.*)
  95. *(.jcr)
  96. _data_end = ABSOLUTE(.);
  97. } >dram_seg
  98. .dram0.rodata :
  99. {
  100. _rodata_start = ABSOLUTE(.);
  101. *(.rodata)
  102. *(.rodata.*)
  103. *(.gnu.linkonce.r.*)
  104. *(.rodata1)
  105. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  106. *(.xt_except_table)
  107. *(.gcc_except_table)
  108. *(.gnu.linkonce.e.*)
  109. *(.gnu.version_r)
  110. *(.eh_frame)
  111. . = (. + 3) & ~ 3;
  112. /* C++ constructor and destructor tables, properly ordered: */
  113. __init_array_start = ABSOLUTE(.);
  114. KEEP (*crtbegin.*(.ctors))
  115. KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
  116. KEEP (*(SORT(.ctors.*)))
  117. KEEP (*(.ctors))
  118. __init_array_end = ABSOLUTE(.);
  119. KEEP (*crtbegin.*(.dtors))
  120. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  121. KEEP (*(SORT(.dtors.*)))
  122. KEEP (*(.dtors))
  123. /* C++ exception handlers table: */
  124. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  125. *(.xt_except_desc)
  126. *(.gnu.linkonce.h.*)
  127. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  128. *(.xt_except_desc_end)
  129. *(.dynamic)
  130. *(.gnu.version_d)
  131. _rodata_end = ABSOLUTE(.);
  132. /* Literals are also RO data. */
  133. _lit4_start = ABSOLUTE(.);
  134. *(*.lit4)
  135. *(.lit4.*)
  136. *(.gnu.linkonce.lit4.*)
  137. _lit4_end = ABSOLUTE(.);
  138. . = ALIGN(4);
  139. } >dram_seg
  140. .iram.text :
  141. {
  142. _stext = .;
  143. _text_start = ABSOLUTE(.);
  144. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  145. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  146. *(.fini.literal)
  147. *(.fini)
  148. *(.gnu.version)
  149. _text_end = ABSOLUTE(.);
  150. _etext = .;
  151. } > iram_seg
  152. }