@@ -79,6 +79,16 @@ FLASH_CONFIG_FIELD_SIZE = 0x10;
7979#error MBED_CONFIGURED_ROM_BANK_IROM1_START too small and will overwrite interrupts and flash config
8080#endif
8181
82+ /* Specify the ELF segments (program headers) */
83+ PHDRS
84+ {
85+ text PT_LOAD FLAGS (5 ); /* read + execute */
86+ ram_vector_table PT_LOAD FLAGS (6 ); /* read + write */
87+ ram_noinit PT_LOAD FLAGS (6 ); /* read + write */
88+ ram_init PT_LOAD FLAGS (6 ); /* read + write */
89+ sram_l PT_LOAD FLAGS (6 ); /* read + write */
90+ }
91+
8292/* Specify the memory areas */
8393MEMORY
8494{
@@ -102,14 +112,14 @@ SECTIONS
102112 . = ALIGN (8 );
103113 KEEP (*(.isr_vector )) /* Startup code */
104114 . = ALIGN (8 );
105- } > m_text AT> m_text
115+ } > m_text AT> m_text :text
106116
107117 /* FCF to absolute address of 0x400, but only if bootloader is not present. */
108118#if !IS_BOOTLOADER_PRESENT
109119 .flash_config VTOR_TABLE_SIZE :
110120 {
111121 KEEP (*(.FlashConfig )) /* Flash Configuration Field (FCF) */
112- } > m_text AT> m_text
122+ } > m_text AT> m_text :text
113123#else
114124 /DISCARD/ : {
115125 *(.FlashConfig )
@@ -130,19 +140,19 @@ SECTIONS
130140 KEEP (*(.init ))
131141 KEEP (*(.fini ))
132142 . = ALIGN (8 );
133- } > m_text
143+ } > m_text AT> m_text :text
134144
135145 .ARM.extab :
136146 {
137147 *(.ARM .extab * .gnu .linkonce .armextab .*)
138- } > m_text
148+ } > m_text AT> m_text :text
139149
140150 .ARM :
141151 {
142152 __exidx_start = .;
143153 *(.ARM .exidx *)
144154 __exidx_end = .;
145- } > m_text
155+ } > m_text AT> m_text :text
146156
147157 .ctors :
148158 {
@@ -166,7 +176,7 @@ SECTIONS
166176 KEEP (*(SORT (.ctors .*)))
167177 KEEP (*(.ctors ))
168178 __CTOR_END__ = .;
169- } > m_text
179+ } > m_text AT> m_text :text
170180
171181 .dtors :
172182 {
@@ -177,41 +187,30 @@ SECTIONS
177187 KEEP (*(SORT (.dtors .*)))
178188 KEEP (*(.dtors ))
179189 __DTOR_END__ = .;
180- } > m_text
190+ } > m_text AT> m_text :text
181191
182192 .preinit_array :
183193 {
184194 PROVIDE_HIDDEN (__preinit_array_start = .);
185195 KEEP (*(.preinit_array *))
186196 PROVIDE_HIDDEN (__preinit_array_end = .);
187- } > m_text
197+ } > m_text AT> m_text :text
188198
189199 .init_array :
190200 {
191201 PROVIDE_HIDDEN (__init_array_start = .);
192202 KEEP (*(SORT (.init_array .*)))
193203 KEEP (*(.init_array *))
194204 PROVIDE_HIDDEN (__init_array_end = .);
195- } > m_text
205+ } > m_text AT> m_text :text
196206
197207 .fini_array :
198208 {
199209 PROVIDE_HIDDEN (__fini_array_start = .);
200210 KEEP (*(SORT (.fini_array .*)))
201211 KEEP (*(.fini_array *))
202212 PROVIDE_HIDDEN (__fini_array_end = .);
203- } > m_text
204-
205- .interrupts_ram :
206- {
207- . = ALIGN (8 );
208- __VECTOR_RAM__ = .;
209- __interrupts_ram_start__ = .; /* Create a global symbol at data start */
210- *(.m_interrupts_ram ) /* This is a user defined section */
211- . += M_VECTOR_RAM_SIZE;
212- . = ALIGN (8 );
213- __interrupts_ram_end__ = .; /* Define a global symbol at data end */
214- } > m_sram_u
213+ } > m_text AT> m_text :text
215214
216215#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
217216 /* Stick the crash data ram at the start of sram_l */
@@ -224,7 +223,7 @@ SECTIONS
224223 . += M_CRASH_DATA_RAM_SIZE;
225224 . = ALIGN (8 );
226225 __CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
227- } > m_sram_u
226+ } > m_sram_l :sram_l
228227#endif
229228
230229 /* Fill the entire sram_l with the heap 0 section. */
@@ -233,11 +232,22 @@ SECTIONS
233232 __mbed_sbrk_start_0 = .;
234233 . += (ORIGIN (m_sram_l) + LENGTH (m_sram_l) - .);
235234 __mbed_krbs_start_0 = .;
236- } > m_sram_l
235+ } > m_sram_l :sram_l
237236
238237 __VECTOR_RAM = DEFINED (__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN (m_interrupts);
239238 __RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED (__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0 ;
240239
240+ .interrupts_ram :
241+ {
242+ . = ALIGN (8 );
243+ __VECTOR_RAM__ = .;
244+ __interrupts_ram_start__ = .; /* Create a global symbol at data start */
245+ *(.m_interrupts_ram ) /* This is a user defined section */
246+ . += M_VECTOR_RAM_SIZE;
247+ . = ALIGN (8 );
248+ __interrupts_ram_end__ = .; /* Define a global symbol at data end */
249+ } > m_sram_u :ram_vector_table
250+
241251 .data : ALIGN (8 )
242252 {
243253 PROVIDE (__etext = LOADADDR (.data )); /* Define a global symbol at end of code, */
@@ -249,7 +259,7 @@ SECTIONS
249259 KEEP (*(.jcr *))
250260 . = ALIGN (8 );
251261 __data_end__ = .; /* define a global symbol at data end */
252- } > m_sram_u AT > m_text
262+ } > m_sram_u AT > m_text :ram_init
253263
254264 __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
255265 text_end = ORIGIN (m_text) + LENGTH (m_text);
@@ -267,7 +277,7 @@ SECTIONS
267277 KEEP (*(.keep .uninitialized ))
268278 . = ALIGN (32 );
269279 __uninitialized_end = .;
270- } > m_sram_u
280+ } > m_sram_u AT> m_sram_u :ram_noinit
271281
272282 USB_RAM_GAP = DEFINED (__usb_ram_size__) ? __usb_ram_size__ : 0x800 ;
273283
@@ -286,7 +296,7 @@ SECTIONS
286296 . = ALIGN (8 );
287297 __bss_end__ = .;
288298 __END_BSS = .;
289- } > m_sram_u
299+ } > m_sram_u AT> m_sram_u :ram_noinit
290300
291301 .heap : ALIGN (8 )
292302 {
@@ -301,19 +311,19 @@ SECTIONS
301311 __mbed_krbs_start = .;
302312 __HeapLimit = .;
303313 __heap_limit = .; /* Add for _sbrk */
304- } > m_sram_u
314+ } > m_sram_u AT> m_sram_u :ram_noinit
305315
306316 /* USB RAM sections. These live inside a "gap" created in .bss. */
307317 m_usb_bdt USB_RAM_START (OVERLAY) :
308318 {
309319 *(m_usb_bdt)
310320 USB_RAM_BDT_END = .;
311- }
321+ } :ram_noinit
312322
313323 m_usb_global USB_RAM_BDT_END (OVERLAY) :
314324 {
315325 *(m_usb_global)
316- }
326+ } :ram_noinit
317327
318328 /* Initializes stack on the end of block */
319329 __StackTop = ORIGIN (m_sram_u) + LENGTH (m_sram_u);
0 commit comments