Skip to content

Commit bb077a3

Browse files
sylvioalvescarlescufi
authored andcommitted
soc: esp32c3: linker changes to enable newlibc and cpp
Adds linker changes to enable cpp and newlibc code. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 3b83e39 commit bb077a3

File tree

1 file changed

+14
-28
lines changed

1 file changed

+14
-28
lines changed

soc/riscv/esp32c3/linker.ld

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,7 @@ SECTIONS
142142
__eh_frame = ABSOLUTE(.);
143143
KEEP(*(.eh_frame))
144144
. = (. + 7) & ~ 3;
145-
/*
146-
* C++ constructor and destructor tables
147-
* Don't include anything from crtbegin.o or crtend.o, as IDF doesn't use toolchain crt.
148-
*
149-
* RISC-V gcc is configured with --enable-initfini-array so it emits an .init_array section instead.
150-
* But the init_priority sections will be sorted for iteration in ascending order during startup.
151-
* The rest of the init_array sections is sorted for iteration in descending order during startup, however.
152-
* Hence a different section is generated for the init_priority functions which is iterated in
153-
* ascending order during startup. The corresponding code can be found in startup.c.
154-
*/
155-
__init_priority_array_start = ABSOLUTE(.);
156-
KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array.*))
157-
__init_priority_array_end = ABSOLUTE(.);
158-
__init_array_start = ABSOLUTE(.);
159-
KEEP (*(EXCLUDE_FILE (*crtend.* *crtbegin.*) .init_array))
160-
__init_array_end = ABSOLUTE(.);
161-
KEEP (*crtbegin.*(.dtors))
162-
KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
163-
KEEP (*(SORT(.dtors.*)))
164-
KEEP (*(.dtors))
145+
165146
/* C++ exception handlers table: */
166147
__XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
167148
*(.xt_except_desc)
@@ -185,7 +166,7 @@ SECTIONS
185166
*(.tbss)
186167
*(.tbss.*)
187168
*(.srodata)
188-
*(".srodata.*")
169+
*(.srodata.*)
189170
*(.rodata)
190171
*(.rodata.*)
191172
*(.rodata_wlog)
@@ -200,12 +181,12 @@ SECTIONS
200181
#pragma push_macro("GROUP_ROM_LINK_IN")
201182
#undef GROUP_ROM_LINK_IN
202183
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
203-
#include "linker/common-rom/common-rom-kernel-devices.ld"
204-
#include "linker/common-rom/common-rom-cpp.ld"
205-
#include "linker/common-rom/common-rom-net.ld"
206-
#include "linker/common-rom/common-rom-bt.ld"
207-
#include "linker/common-rom/common-rom-debug.ld"
208-
#include "linker/common-rom/common-rom-misc.ld"
184+
#include <zephyr/linker/common-rom/common-rom-cpp.ld>
185+
#include <zephyr/linker/common-rom/common-rom-kernel-devices.ld>
186+
#include <zephyr/linker/common-rom/common-rom-net.ld>
187+
#include <zephyr/linker/common-rom/common-rom-bt.ld>
188+
#include <zephyr/linker/common-rom/common-rom-debug.ld>
189+
#include <zephyr/linker/common-rom/common-rom-misc.ld>
209190
#pragma pop_macro("GROUP_ROM_LINK_IN")
210191

211192
.iram0.text : ALIGN(4)
@@ -254,6 +235,7 @@ SECTIONS
254235
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
255236
*libsoc.a:rtc_*.*(.literal .text .literal.* .text.*)
256237
*libsoc.a:cpu_util.*(.literal .text .literal.* .text.*)
238+
*liblib__libc__newlib.a:string.*(.literal .text .literal.* .text.*)
257239
*liblib__libc__minimal.a:string.*(.literal .text .literal.* .text.*)
258240
*libphy.a:( .phyiram .phyiram.*)
259241
*libgcov.a:(.literal .text .literal.* .text.*)
@@ -350,21 +332,25 @@ SECTIONS
350332
. = ALIGN(4);
351333
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
352334

335+
#include <zephyr/linker/cplusplus-rom.ld>
336+
#include <zephyr/linker/thread-local-storage.ld>
353337
#include <snippets-data-sections.ld>
354338
#include <zephyr/linker/common-ram.ld>
355339
#include <snippets-ram-sections.ld>
340+
#include <zephyr/linker/cplusplus-ram.ld>
356341

357342
/* logging sections should be placed in RAM area to avoid flash cache disabled issues */
358343
#pragma push_macro("GROUP_ROM_LINK_IN")
359344
#undef GROUP_ROM_LINK_IN
360345
#define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN
361-
#include "linker/common-rom/common-rom-logging.ld"
346+
#include <zephyr/linker/common-rom/common-rom-logging.ld>
362347
#pragma pop_macro("GROUP_ROM_LINK_IN")
363348

364349
.dummy.dram.data :
365350
{
366351
. = ALIGN(4);
367352
#include <snippets-rwdata.ld>
353+
_end = ABSOLUTE(.);
368354
_data_end = ABSOLUTE(.);
369355
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
370356

0 commit comments

Comments
 (0)