/ firmware / targets / esp32s3.ld
esp32s3.ld
  1  /* Linker script for the ESP32-S3 */
  2  
  3  
  4  MEMORY
  5  {
  6      /* Note: DRAM and IRAM below are actually in the same 416K address space. */
  7      DRAM (rw) : ORIGIN = 0x3FC88000, LENGTH = 416K /* Internal SRAM 1 (data bus) */
  8      IRAM (x)  : ORIGIN = 0x40370000, LENGTH = 416K /* Internal SRAM 1 (instruction bus) */
  9  
 10      /* Note: DROM and IROM below are actually in the same 32M address space. */
 11      DROM (r)  : ORIGIN = 0x3C000000, LENGTH = 32M /* Data bus (read-only) */
 12      IROM (rx) : ORIGIN = 0x42000000, LENGTH = 32M /* Instruction bus */
 13  }
 14  
 15  /* The entry point. It is set in the image flashed to the chip, so must be
 16   * defined.
 17   */
 18  ENTRY(call_start_cpu0)
 19  
 20  SECTIONS
 21  {
 22      /* Put the stack at the bottom of DRAM, so that the application will
 23       * crash on stack overflow instead of silently corrupting memory.
 24       * See: http://blog.japaric.io/stack-overflow-protection/ */
 25      .stack (NOLOAD) :
 26      {
 27          . = ALIGN(16);
 28          . += _stack_size;
 29          _stack_top = .;
 30      } >DRAM
 31  
 32      /* Constant literals and code. Loaded into IRAM for now. Eventually, most
 33       * code should be executed directly from flash.
 34       * Note that literals must be before code for the l32r instruction to work.
 35       */
 36  .text.call_start_cpu0 : ALIGN(4)
 37  {
 38      *(.literal.call_start_cpu0)
 39      *(.text.call_start_cpu0)
 40  } >IRAM AT >DRAM
 41  
 42  /* All other code and literals */
 43  .text : ALIGN(4)
 44  {
 45      *(.literal .text)
 46      *(.literal.* .text.*)
 47      *(.text)
 48      *(.text.*)
 49  } >IRAM AT >DRAM
 50  
 51      /* Constant global variables.
 52       * They are loaded in DRAM for ease of use. Eventually they should be stored
 53       * in flash and loaded directly from there but they're kept in RAM to make
 54       * sure they can always be accessed (even in interrupts).
 55       */
 56      .rodata : ALIGN(4)
 57      {
 58          *(.rodata)
 59          *(.rodata.*)
 60      } >DRAM
 61  
 62      /* Mutable global variables.
 63       */
 64      .data : ALIGN(4)
 65      {
 66          _sdata = ABSOLUTE(.);
 67          *(.data)
 68          *(.data.*)
 69          _edata = ABSOLUTE(.);
 70      } >DRAM
 71  
 72      /* Check that the boot ROM stack (for the APP CPU) does not overlap with the
 73       * data that is loaded by the boot ROM. There may be ways to avoid this
 74       * issue if it occurs in practice.
 75       * The magic value here is _stack_sentry in the boot ROM ELF file.
 76       */
 77      ASSERT(_edata < 0x3ffe1320, "the .data section overlaps with the stack used by the boot ROM, possibly causing corruption at startup")
 78  
 79      /* Global variables that are mutable and zero-initialized.
 80       * These must be zeroed at startup (unlike data, which is loaded by the
 81       * bootloader).
 82       */
 83      .bss (NOLOAD) : ALIGN(4)
 84      {
 85          . = ALIGN (4);
 86          _sbss = ABSOLUTE(.);
 87          *(.bss)
 88          *(.bss.*)
 89          . = ALIGN (4);
 90          _ebss = ABSOLUTE(.);
 91      } >DRAM
 92  }
 93  
 94  /* For the garbage collector.
 95   */
 96  _globals_start = _sdata;
 97  _globals_end = _ebss;
 98  _heap_start = _ebss;
 99  _heap_end = ORIGIN(DRAM) + LENGTH(DRAM);
100  
101  _stack_size = 4K;
102  
103  /* From ESP-IDF:
104   * components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
105   * This is the subset that is sometimes used by LLVM during codegen, and thus
106   * must always be present.
107   */
108  memset = 0x400011e8;
109  memcpy = 0x400011f4;
110  memmove = 0x40001200;
111  memcmp = 0x4000120c;
112  
113  /* From ESP-IDF:
114   * components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
115   * These are called from LLVM during codegen. The original license is Apache
116   * 2.0, but I believe that a list of function names and addresses can't really
117   * be copyrighted.
118   */
119  __absvdi2 = 0x4000216c;
120  __absvsi2 = 0x40002178;
121  __adddf3 = 0x40002184;
122  __addsf3 = 0x40002190;
123  __addvdi3 = 0x4000219c;
124  __addvsi3 = 0x400021a8;
125  __ashldi3 = 0x400021b4;
126  __ashrdi3 = 0x400021c0;
127  __bswapdi2 = 0x400021cc;
128  __bswapsi2 = 0x400021d8;
129  __clear_cache = 0x400021e4;
130  __clrsbdi2 = 0x400021f0;
131  __clrsbsi2 = 0x400021fc;
132  __clzdi2 = 0x40002208;
133  __clzsi2 = 0x40002214;
134  __cmpdi2 = 0x40002220;
135  __ctzdi2 = 0x4000222c;
136  __ctzsi2 = 0x40002238;
137  __divdc3 = 0x40002244;
138  __divdf3 = 0x40002250;
139  __divdi3 = 0x4000225c;
140  __divsc3 = 0x40002268;
141  __divsf3 = 0x40002274;
142  __divsi3 = 0x40002280;
143  __eqdf2 = 0x4000228c;
144  __eqsf2 = 0x40002298;
145  __extendsfdf2 = 0x400022a4;
146  __ffsdi2 = 0x400022b0;
147  __ffssi2 = 0x400022bc;
148  __fixdfdi = 0x400022c8;
149  __fixdfsi = 0x400022d4;
150  __fixsfdi = 0x400022e0;
151  __fixsfsi = 0x400022ec;
152  __fixunsdfsi = 0x400022f8;
153  __fixunssfdi = 0x40002304;
154  __fixunssfsi = 0x40002310;
155  __floatdidf = 0x4000231c;
156  __floatdisf = 0x40002328;
157  __floatsidf = 0x40002334;
158  __floatsisf = 0x40002340;
159  __floatundidf = 0x4000234c;
160  __floatundisf = 0x40002358;
161  __floatunsidf = 0x40002364;
162  __floatunsisf = 0x40002370;
163  __gcc_bcmp = 0x4000237c;
164  __gedf2 = 0x40002388;
165  __gesf2 = 0x40002394;
166  __gtdf2 = 0x400023a0;
167  __gtsf2 = 0x400023ac;
168  __ledf2 = 0x400023b8;
169  __lesf2 = 0x400023c4;
170  __lshrdi3 = 0x400023d0;
171  __ltdf2 = 0x400023dc;
172  __ltsf2 = 0x400023e8;
173  __moddi3 = 0x400023f4;
174  __modsi3 = 0x40002400;
175  __muldc3 = 0x4000240c;
176  __muldf3 = 0x40002418;
177  __muldi3 = 0x40002424;
178  __mulsc3 = 0x40002430;
179  __mulsf3 = 0x4000243c;
180  __mulsi3 = 0x40002448;
181  __mulvdi3 = 0x40002454;
182  __mulvsi3 = 0x40002460;
183  __nedf2 = 0x4000246c;
184  __negdf2 = 0x40002478;
185  __negdi2 = 0x40002484;
186  __negsf2 = 0x40002490;
187  __negvdi2 = 0x4000249c;
188  __negvsi2 = 0x400024a8;
189  __nesf2 = 0x400024b4;
190  __paritysi2 = 0x400024c0;
191  __popcountdi2 = 0x400024cc;
192  __popcountsi2 = 0x400024d8;
193  __powidf2 = 0x400024e4;
194  __powisf2 = 0x400024f0;
195  __subdf3 = 0x400024fc;
196  __subsf3 = 0x40002508;
197  __subvdi3 = 0x40002514;
198  __subvsi3 = 0x40002520;
199  __truncdfsf2 = 0x4000252c;
200  __ucmpdi2 = 0x40002538;
201  __udivdi3 = 0x40002544;
202  __udivmoddi4 = 0x40002550;
203  __udivsi3 = 0x4000255c;
204  __udiv_w_sdiv = 0x40002568;
205  __umoddi3 = 0x40002574;
206  __umodsi3 = 0x40002580;
207  __unorddf2 = 0x4000258c;
208  __unordsf2 = 0x40002598;