github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/targets/esp32.ld (about) 1 /* Linker script for the ESP32 */ 2 3 MEMORY 4 { 5 /* Data RAM. Allows byte access. 6 * There are various data RAM regions: 7 * SRAM2: 0x3FFA_E000..0x3FFD_FFFF (72 + 128 = 200K) 8 * SRAM1: 0x3FFE_0000..0x3FFF_FFFF (128K) 9 * This gives us 328K of contiguous RAM, which is the largest span possible. 10 * SRAM1 has other addresses as well but the datasheet seems to indicate 11 * these are aliases. 12 */ 13 DRAM (rw) : ORIGIN = 0x3FFAE000, LENGTH = 200K + 128K /* Internal SRAM 1 + 2 */ 14 15 /* Instruction RAM. */ 16 IRAM (x) : ORIGIN = 0x40080000, LENGTH = 128K /* Internal SRAM 0 */ 17 } 18 19 /* The entry point. It is set in the image flashed to the chip, so must be 20 * defined. 21 */ 22 ENTRY(call_start_cpu0) 23 24 SECTIONS 25 { 26 /* Constant literals and code. Loaded into IRAM for now. Eventually, most 27 * code should be executed directly from flash. 28 * Note that literals must be before code for the l32r instruction to work. 29 */ 30 .text : ALIGN(4) 31 { 32 *(.literal.text.call_start_cpu0) 33 *(.text.call_start_cpu0) 34 *(.literal .text) 35 *(.literal.* .text.*) 36 } >IRAM 37 38 /* Put the stack at the bottom of DRAM, so that the application will 39 * crash on stack overflow instead of silently corrupting memory. 40 * See: http://blog.japaric.io/stack-overflow-protection/ */ 41 .stack (NOLOAD) : 42 { 43 . = ALIGN(16); 44 . += _stack_size; 45 _stack_top = .; 46 } >DRAM 47 48 /* Constant global variables. 49 * They are loaded in DRAM for ease of use. Eventually they should be stored 50 * in flash and loaded directly from there but they're kept in RAM to make 51 * sure they can always be accessed (even in interrupts). 52 */ 53 .rodata : ALIGN(4) 54 { 55 *(.rodata) 56 *(.rodata.*) 57 } >DRAM 58 59 /* Mutable global variables. 60 */ 61 .data : ALIGN(4) 62 { 63 _sdata = ABSOLUTE(.); 64 *(.data) 65 *(.data.*) 66 _edata = ABSOLUTE(.); 67 } >DRAM 68 69 /* Check that the boot ROM stack (for the APP CPU) does not overlap with the 70 * data that is loaded by the boot ROM. There may be ways to avoid this 71 * issue if it occurs in practice. 72 * The magic value here is _stack_sentry in the boot ROM ELF file. 73 */ 74 ASSERT(_edata < 0x3ffe1320, "the .data section overlaps with the stack used by the boot ROM, possibly causing corruption at startup") 75 76 /* Global variables that are mutable and zero-initialized. 77 * These must be zeroed at startup (unlike data, which is loaded by the 78 * bootloader). 79 */ 80 .bss (NOLOAD) : ALIGN(4) 81 { 82 . = ALIGN (4); 83 _sbss = ABSOLUTE(.); 84 *(.bss) 85 *(.bss.*) 86 . = ALIGN (4); 87 _ebss = ABSOLUTE(.); 88 } >DRAM 89 } 90 91 /* For the garbage collector. 92 */ 93 _globals_start = _sdata; 94 _globals_end = _ebss; 95 _heap_start = _ebss; 96 _heap_end = ORIGIN(DRAM) + LENGTH(DRAM); 97 98 _stack_size = 4K; 99 100 /* From ESP-IDF: 101 * components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld 102 * This is the subset that is sometimes used by LLVM during codegen, and thus 103 * must always be present. 104 */ 105 memcpy = 0x4000c2c8; 106 memmove = 0x4000c3c0; 107 memset = 0x4000c44c; 108 109 /* From ESP-IDF: 110 * components/esp_rom/esp32/ld/esp32.rom.libgcc.ld 111 * These are called from LLVM during codegen. The original license is Apache 112 * 2.0, but I believe that a list of function names and addresses can't really 113 * be copyrighted. 114 */ 115 __absvdi2 = 0x4006387c; 116 __absvsi2 = 0x40063868; 117 __adddf3 = 0x40002590; 118 __addsf3 = 0x400020e8; 119 __addvdi3 = 0x40002cbc; 120 __addvsi3 = 0x40002c98; 121 __ashldi3 = 0x4000c818; 122 __ashrdi3 = 0x4000c830; 123 __bswapdi2 = 0x40064b08; 124 __bswapsi2 = 0x40064ae0; 125 __clrsbdi2 = 0x40064b7c; 126 __clrsbsi2 = 0x40064b64; 127 __clzdi2 = 0x4000ca50; 128 __clzsi2 = 0x4000c7e8; 129 __cmpdi2 = 0x40063820; 130 __ctzdi2 = 0x4000ca64; 131 __ctzsi2 = 0x4000c7f0; 132 __divdc3 = 0x400645a4; 133 __divdf3 = 0x40002954; 134 __divdi3 = 0x4000ca84; 135 __divsi3 = 0x4000c7b8; 136 __eqdf2 = 0x400636a8; 137 __eqsf2 = 0x40063374; 138 __extendsfdf2 = 0x40002c34; 139 __ffsdi2 = 0x4000ca2c; 140 __ffssi2 = 0x4000c804; 141 __fixdfdi = 0x40002ac4; 142 __fixdfsi = 0x40002a78; 143 __fixsfdi = 0x4000244c; 144 __fixsfsi = 0x4000240c; 145 __fixunsdfsi = 0x40002b30; 146 __fixunssfdi = 0x40002504; 147 __fixunssfsi = 0x400024ac; 148 __floatdidf = 0x4000c988; 149 __floatdisf = 0x4000c8c0; 150 __floatsidf = 0x4000c944; 151 __floatsisf = 0x4000c870; 152 __floatundidf = 0x4000c978; 153 __floatundisf = 0x4000c8b0; 154 __floatunsidf = 0x4000c938; 155 __floatunsisf = 0x4000c864; 156 __gcc_bcmp = 0x40064a70; 157 __gedf2 = 0x40063768; 158 __gesf2 = 0x4006340c; 159 __gtdf2 = 0x400636dc; 160 __gtsf2 = 0x400633a0; 161 __ledf2 = 0x40063704; 162 __lesf2 = 0x400633c0; 163 __lshrdi3 = 0x4000c84c; 164 __ltdf2 = 0x40063790; 165 __ltsf2 = 0x4006342c; 166 __moddi3 = 0x4000cd4c; 167 __modsi3 = 0x4000c7c0; 168 __muldc3 = 0x40063c90; 169 __muldf3 = 0x4006358c; 170 __muldi3 = 0x4000c9fc; 171 __mulsf3 = 0x400632c8; 172 __mulsi3 = 0x4000c7b0; 173 __mulvdi3 = 0x40002d78; 174 __mulvsi3 = 0x40002d60; 175 __nedf2 = 0x400636a8; 176 __negdf2 = 0x400634a0; 177 __negdi2 = 0x4000ca14; 178 __negsf2 = 0x400020c0; 179 __negvdi2 = 0x40002e98; 180 __negvsi2 = 0x40002e78; 181 __nesf2 = 0x40063374; 182 __nsau_data = 0x3ff96544; 183 __paritysi2 = 0x40002f3c; 184 __popcount_tab = 0x3ff96544; 185 __popcountdi2 = 0x40002ef8; 186 __popcountsi2 = 0x40002ed0; 187 __powidf2 = 0x400638e4; 188 __subdf3 = 0x400026e4; 189 __subsf3 = 0x400021d0; 190 __subvdi3 = 0x40002d20; 191 __subvsi3 = 0x40002cf8; 192 __truncdfsf2 = 0x40002b90; 193 __ucmpdi2 = 0x40063840; 194 __udiv_w_sdiv = 0x40064bec; 195 __udivdi3 = 0x4000cff8; 196 __udivmoddi4 = 0x40064bf4; 197 __udivsi3 = 0x4000c7c8; 198 __umoddi3 = 0x4000d280; 199 __umodsi3 = 0x4000c7d0; 200 __umulsidi3 = 0x4000c7d8; 201 __unorddf2 = 0x400637f4; 202 __unordsf2 = 0x40063478;