Skip to content

Commit 002cbb6

Browse files
committed
Place IRAM and FLASH data in separate segments to resolve section conflicts issue
Thanks to esp8266/Arduino#5116
1 parent 77fb3df commit 002cbb6

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
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,32 @@
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+
#define STORE_TYPEDEF_ATTR __attribute__((aligned(4), packed))
65
#define STORE_ATTR __attribute__((aligned(4)))
76

87
#define DMEM_ATTR __attribute__((section(".bss")))
98
#define SHMEM_ATTR
109

11-
#ifdef ICACHE_FLASH
12-
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
10+
// The following two macros cause a parameter to be enclosed in quotes
11+
#define ICACHE_RAM_ATTR __attribute__((section(".iram.text")))
12+
// by the preopressor (i.e. for concatenating ints to strings)
1313
#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_STRINGIZE_NX(A) #A
15+
#define ATTR_STRINGIZE__(A) __ICACHE_STRINGIZE_NX(A)
16+
#define ICACHE_FLASH_ATTR \
17+
__attribute__(( \
18+
section("\".irom0.text." __FILE__ "." ATTR_STRINGIZE__(__LINE__) "." ATTR_STRINGIZE__(__COUNTER__) "\"")))
19+
#define IRAM_ATTR \
20+
__attribute__( \
21+
(section("\".iram.text." __FILE__ "." ATTR_STRINGIZE__(__LINE__) "." ATTR_STRINGIZE__(__COUNTER__) "\"")))
22+
#define ICACHE_RODATA_ATTR \
23+
__attribute__( \
24+
(section("\".irom.text." __FILE__ "." ATTR_STRINGIZE__(__LINE__) "." ATTR_STRINGIZE__(__COUNTER__) "\"")))
1825

1926
#define STORE_ATTR __attribute__((aligned(4)))
2027

2128
#ifdef ENABLE_GDB
22-
#define GDB_IRAM_ATTR IRAM_ATTR
29+
#define GDB_IRAM_ATTR IRAM_ATTR
2330
#else
24-
#define GDB_IRAM_ATTR
31+
#define GDB_IRAM_ATTR
2532
#endif

0 commit comments

Comments
 (0)