Skip to content

Commit 6ae1fbf

Browse files
committed
Place IRAM and FLASH data in separate segments to resolve issues with section conflicts
Thanks to esp8266/Arduino#5116 Commonly occurs when attempting to inline header methods, generally more of a problem with GCC 4.8.
1 parent 76fe858 commit 6ae1fbf

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Sming/Arch/Esp8266/Compiler/ld/common.ld

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ SECTIONS
107107
*libm.a:(.literal .text .literal.* .text.*)
108108

109109
*(.rodata._ZTV*) /* C++ vtables */
110-
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text .irom.debug.*)
110+
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom0.text.* .irom.text .irom.debug.*)
111111

112112
/* Generated libraries */
113113
*liblwip2.a:(.literal .text .literal.* .text.*)
@@ -160,7 +160,7 @@ SECTIONS
160160
*(.init.literal)
161161
*(.init)
162162
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
163-
*(.iram.literal .iram.text.literal .iram.text)
163+
*(.iram.literal .iram.text.literal .iram.text .iram.text.*)
164164
*(.fini.literal)
165165
*(.fini)
166166
*(.gnu.version)
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
// ESP8266 attribute definitions (previously in c_types.h)
22
#pragma once
33

4-
#define IRAM_ATTR __attribute__((section(".iram.text")))
5-
#define STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
4+
// http://stackoverflow.com/a/35441900
5+
#define MACROQUOT(x) #x
6+
#define MACROQUOTE(x) MACROQUOT(x)
7+
8+
#define STORE_TYPEDEF_ATTR __attribute__((aligned(4), packed))
69
#define STORE_ATTR __attribute__((aligned(4)))
710

811
#define DMEM_ATTR __attribute__((section(".bss")))
912
#define SHMEM_ATTR
1013

11-
#ifdef ICACHE_FLASH
12-
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
13-
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
14-
#else
15-
#define ICACHE_FLASH_ATTR
16-
#define ICACHE_RODATA_ATTR
17-
#endif
14+
#define ICACHE_FLASH_ATTR \
15+
__attribute__((section(".irom0.text." __FILE__ MACROQUOTE(__LINE__) MACROQUOTE(__COUNTER__))))
16+
#define ICACHE_RAM_ATTR \
17+
__attribute__((section(".iram.text." __FILE__ MACROQUOTE(__LINE__) MACROQUOTE(__COUNTER__))))
18+
#define ICACHE_RODATA_ATTR \
19+
__attribute__((section(".irom0.text." __FILE__ MACROQUOTE(__LINE__) MACROQUOTE(__COUNTER__))))
20+
21+
#define IRAM_ATTR ICACHE_RAM_ATTR
1822

1923
#define STORE_ATTR __attribute__((aligned(4)))
2024

2125
#ifdef ENABLE_GDB
22-
#define GDB_IRAM_ATTR IRAM_ATTR
26+
#define GDB_IRAM_ATTR IRAM_ATTR
2327
#else
24-
#define GDB_IRAM_ATTR
28+
#define GDB_IRAM_ATTR
2529
#endif

0 commit comments

Comments
 (0)