Skip to content

Commit 9d4d144

Browse files
sylvioalvescarlescufi
authored andcommitted
linker: esp32s2: changes to enable newlibc and cpp support
This PR adds missing configuration to enable newlibc and cpp code to run in ESP32S2 SoC. This isn't enough though. Toolchain changes are also needed and will come up next. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 54aa7a9 commit 9d4d144

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

soc/xtensa/esp32s2/linker.ld

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ ENTRY(CONFIG_KERNEL_ENTRY)
7979

8080
_rom_store_table = 0;
8181

82+
_heap_sentry = 0x3fffe710;
83+
8284
SECTIONS
8385
{
8486
/* Reserve space for MCUboot header in the binary */
@@ -131,9 +133,6 @@ SECTIONS
131133
{
132134
_rodata_start = ABSOLUTE(.);
133135

134-
*(.rodata_desc .rodata_desc.*)
135-
*(.rodata_custom_desc .rodata_custom_desc.*)
136-
137136
. = ALIGN(4);
138137
#include <snippets-rodata.ld>
139138

@@ -154,14 +153,7 @@ SECTIONS
154153
__eh_frame = ABSOLUTE(.);
155154
KEEP(*(.eh_frame))
156155
. = (. + 7) & ~ 3;
157-
/* C++ constructor and destructor tables */
158-
__init_array_start = ABSOLUTE(.);
159-
KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .ctors SORT(.ctors.*)))
160-
__init_array_end = ABSOLUTE(.);
161-
KEEP (*crtbegin.*(.dtors))
162-
KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
163-
KEEP (*(SORT(.dtors.*)))
164-
KEEP (*(.dtors))
156+
165157
/* C++ exception handlers table: */
166158
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
167159
*(.xt_except_desc)
@@ -193,12 +185,12 @@ SECTIONS
193185
#pragma push_macro("GROUP_ROM_LINK_IN")
194186
#undef GROUP_ROM_LINK_IN
195187
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
196-
#include "linker/common-rom/common-rom-kernel-devices.ld"
197-
#include "linker/common-rom/common-rom-cpp.ld"
198-
#include "linker/common-rom/common-rom-net.ld"
199-
#include "linker/common-rom/common-rom-bt.ld"
200-
#include "linker/common-rom/common-rom-debug.ld"
201-
#include "linker/common-rom/common-rom-misc.ld"
188+
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
189+
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
190+
#include <zephyr/linker/common-rom/common-rom-net.ld>
191+
#include <zephyr/linker/common-rom/common-rom-bt.ld>
192+
#include <zephyr/linker/common-rom/common-rom-debug.ld>
193+
#include <zephyr/linker/common-rom/common-rom-misc.ld>
202194
#pragma pop_macro("GROUP_ROM_LINK_IN")
203195

204196
/* Send .iram0 code to iram */
@@ -274,6 +266,7 @@ SECTIONS
274266
*libzephyr.a:log_backend_uart.*(.literal .text .literal.* .text.*)
275267
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
276268
*liblib__libc__minimal.a:string.*(.literal .text .literal.* .text.*)
269+
*liblib__libc__newlib.a:string.*(.literal .text .literal.* .text.*)
277270
*libphy.a:( .phyiram .phyiram.*)
278271
*libgcov.a:(.literal .text .literal.* .text.*)
279272

@@ -367,22 +360,25 @@ SECTIONS
367360
. = ALIGN(4);
368361
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
369362

363+
#include <zephyr/linker/cplusplus-rom.ld>
370364
#include <snippets-data-sections.ld>
371365
#include <zephyr/linker/common-ram.ld>
372366
#include <snippets-ram-sections.ld>
367+
#include <zephyr/linker/cplusplus-ram.ld>
373368

374369
/* logging sections should be placed in RAM area to avoid flash cache disabled issues */
375370
#pragma push_macro("GROUP_ROM_LINK_IN")
376371
#undef GROUP_ROM_LINK_IN
377372
#define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN
378-
#include "linker/common-rom/common-rom-logging.ld"
373+
#include <zephyr/linker/common-rom/common-rom-logging.ld>
379374
#pragma pop_macro("GROUP_ROM_LINK_IN")
380375

381376
.dummy.dram.data :
382377
{
383378
. = ALIGN(4);
384379
#include <snippets-rwdata.ld>
385380
. = ALIGN(4);
381+
_end = ABSOLUTE(.);
386382
_data_end = ABSOLUTE(.);
387383
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
388384

@@ -475,9 +471,38 @@ SECTIONS
475471

476472
#include <zephyr/linker/debug-sections.ld>
477473

478-
SECTION_PROLOGUE(.xtensa.info, 0,)
474+
.xtensa.info 0 : { *(.xtensa.info) }
475+
.xt.insn 0 :
476+
{
477+
KEEP (*(.xt.insn))
478+
KEEP (*(.gnu.linkonce.x.*))
479+
}
480+
.xt.prop 0 :
481+
{
482+
KEEP (*(.xt.prop))
483+
KEEP (*(.xt.prop.*))
484+
KEEP (*(.gnu.linkonce.prop.*))
485+
}
486+
.xt.lit 0 :
487+
{
488+
KEEP (*(.xt.lit))
489+
KEEP (*(.xt.lit.*))
490+
KEEP (*(.gnu.linkonce.p.*))
491+
}
492+
.xt.profile_range 0 :
493+
{
494+
KEEP (*(.xt.profile_range))
495+
KEEP (*(.gnu.linkonce.profile_range.*))
496+
}
497+
.xt.profile_ranges 0 :
498+
{
499+
KEEP (*(.xt.profile_ranges))
500+
KEEP (*(.gnu.linkonce.xt.profile_ranges.*))
501+
}
502+
.xt.profile_files 0 :
479503
{
480-
*(.xtensa.info)
504+
KEEP (*(.xt.profile_files))
505+
KEEP (*(.gnu.linkonce.xt.profile_files.*))
481506
}
482507
}
483508

0 commit comments

Comments
 (0)