Skip to content

Commit 0f5dad3

Browse files
committed
Fix placement of code into RAM, enable gc-sections
Related to #856, #826, #803, #734
1 parent d8f57cb commit 0f5dad3

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

hardware/esp8266com/esp8266/platform.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ compiler.sdk.path={runtime.platform.path}/tools/sdk
1616
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include"
1717

1818
compiler.c.cmd=xtensa-lx106-elf-gcc
19-
compiler.c.flags=-c -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99
19+
compiler.c.flags=-c -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections
2020

2121
compiler.S.cmd=xtensa-lx106-elf-gcc
2222
compiler.S.flags=-c -g -x assembler-with-cpp -MMD
2323

24-
compiler.c.elf.flags=-g -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{build.flash_ld}" -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy
24+
compiler.c.elf.flags=-g -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static "-L{compiler.sdk.path}/lib" "-L{compiler.sdk.path}/ld" "-T{build.flash_ld}" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy
2525

2626
compiler.c.elf.cmd=xtensa-lx106-elf-gcc
2727
compiler.c.elf.libs=-lm -lgcc -lhal -lphy -lnet80211 -llwip -lwpa -lmain -lpp -lsmartconfig -lwps -lcrypto -laxtls
2828

2929
compiler.cpp.cmd=xtensa-lx106-elf-g++
30-
compiler.cpp.flags=-c -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD
30+
compiler.cpp.flags=-c -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
3131

3232
compiler.as.cmd=xtensa-lx106-elf-as
3333

hardware/esp8266com/esp8266/tools/sdk/include/c_types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef enum {
6767

6868
#ifdef ICACHE_FLASH
6969
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
70-
#define ICACHE_RAM_ATTR __attribute__((section(".text")))
70+
#define ICACHE_RAM_ATTR __attribute__((section(".iram.text")))
7171
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
7272
#else
7373
#define ICACHE_FLASH_ATTR

hardware/esp8266com/esp8266/tools/sdk/ld/eagle.app.v6.common.ld

+4-3
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,11 @@ SECTIONS
150150
.irom0.text : ALIGN(4)
151151
{
152152
_irom0_text_start = ABSOLUTE(.);
153-
*core_esp8266_*.o(.literal*, .text*)
154-
*spiffs*.o(.literal*, .text*)
153+
*.c.o(.literal*, .text*)
155154
*.cpp.o(.literal*, .text*)
156155
*libm.a:(.literal .text .literal.* .text.*)
157156
*libsmartconfig.a:(.literal .text .literal.* .text.*)
158-
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
157+
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .irom.text.*)
159158
_irom0_text_end = ABSOLUTE(.);
160159
_flash_code_end = ABSOLUTE(.);
161160
} >irom0_0_seg :irom0_0_phdr
@@ -192,6 +191,8 @@ SECTIONS
192191
*(.init.literal)
193192
*(.init)
194193
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
194+
*.cpp.o(.iram.text)
195+
*.c.o(.iram.text)
195196
*(.fini.literal)
196197
*(.fini)
197198
*(.gnu.version)

0 commit comments

Comments
 (0)