Skip to content

Commit 191d43a

Browse files
committed
migrate linker: CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE can be -1 now
And other things Signed-off-by: Alp Sayin <alpsayin@gmail.com>
1 parent 0de8037 commit 191d43a

File tree

1 file changed

+68
-24
lines changed

1 file changed

+68
-24
lines changed

include/zephyr/arch/microblaze/linker.ld

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020

2121
ENTRY(CONFIG_KERNEL_ENTRY)
2222

23-
#if CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0
24-
_HEAP_SIZE = CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE;
25-
#else
26-
_HEAP_SIZE = 32K;
27-
#endif
28-
2923
SECTIONS
3024
{
3125

3226
#include <zephyr/linker/rel-sections.ld>
27+
28+
#ifdef CONFIG_LLEXT
29+
#include <zephyr/linker/llext-sections.ld>
30+
#endif
31+
32+
GROUP_START(ROMABLE_REGION)
33+
3334
SECTION_PROLOGUE(.text,,)
3435
{
3536
/* microblaze vectors from 0x0 to 0x50 */
@@ -55,7 +56,7 @@ SECTIONS
5556
__text_region_end = .;
5657
__text_region_size = __text_region_end - __text_region_start;
5758

58-
SECTION_PROLOGUE(_EXCEPTION_SECTION_NAME,,)
59+
SECTION_DATA_PROLOGUE(_EXCEPTION_SECTION_NAME,,)
5960
{
6061
KEEP(*(".exception.entry.*"))
6162
*(".exception.other.*")
@@ -80,8 +81,11 @@ SECTIONS
8081
__rodata_region_start = .;
8182

8283
#include <zephyr/linker/common-rom.ld>
84+
/* Located in generated directory. This file is populated by calling
85+
* zephyr_linker_sources(ROM_SECTIONS ...). Useful for grouping iterable RO structs.
86+
*/
87+
#include <snippets-rom-sections.ld>
8388
#include <zephyr/linker/thread-local-storage.ld>
84-
#include <zephyr/linker/cplusplus-rom.ld>
8589

8690
SECTION_PROLOGUE(.rodata,,)
8791
{
@@ -91,14 +95,40 @@ SECTIONS
9195
*(.rodata.*)
9296
*(.gnu.linkonce.r.*)
9397

98+
/* Located in generated directory. This file is populated by the
99+
* zephyr_linker_sources() Cmake function.
100+
*/
94101
#include <snippets-rodata.ld>
95102

96103
} GROUP_LINK_IN(ROMABLE_REGION)
97104

98105
#include <zephyr/linker/cplusplus-rom.ld>
99106

107+
__rodata_end = .;
108+
__rodata_region_end = .;
109+
__rodata_region_size = __rodata_region_end - __rodata_region_start;
110+
111+
GROUP_END(ROMABLE_REGION)
112+
113+
GROUP_START(RAMABLE_REGION)
114+
115+
_image_ram_start = .;
116+
100117
#ifdef CONFIG_CPP
101-
.dtors : {
118+
/* These exist to keep Vitis Microblaze toolchain happy */
119+
SECTION_PROLOGUE(.ctors,,)
120+
{
121+
__CTOR_LIST__ = .;
122+
___CTORS_LIST___ = .;
123+
KEEP (*crtbegin.o(.ctors))
124+
KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors))
125+
KEEP (*(SORT(.ctors.*)))
126+
KEEP (*(.ctors))
127+
__CTOR_END__ = .;
128+
___CTORS_END___ = .;
129+
} GROUP_LINK_IN(RAMABLE_REGION)
130+
SECTION_PROLOGUE(.dtors,,)
131+
{
102132
__DTOR_LIST__ = .;
103133
___DTORS_LIST___ = .;
104134
KEEP (*crtbegin.o(.dtors))
@@ -107,14 +137,10 @@ SECTIONS
107137
KEEP (*(.dtors))
108138
PROVIDE(__DTOR_END__ = .);
109139
PROVIDE(___DTORS_END___ = .);
110-
} > app_ram
140+
} GROUP_LINK_IN(RAMABLE_REGION)
111141
#endif
112142

113-
__rodata_end = .;
114-
__rodata_region_end = .;
115-
__rodata_region_size = __rodata_region_end - __rodata_region_start;
116-
117-
SECTION_PROLOGUE(.sdata2,,)
143+
SECTION_DATA_PROLOGUE(.sdata2,,)
118144
{
119145
. = ALIGN(4);
120146
__sdata2_start = .;
@@ -126,8 +152,10 @@ SECTIONS
126152
} GROUP_LINK_IN(RAMABLE_REGION)
127153

128154
#include <zephyr/linker/common-ram.ld>
155+
#include <zephyr/linker/kobject-data.ld>
156+
#include <zephyr/linker/cplusplus-ram.ld>
129157

130-
SECTION_PROLOGUE(.data,,)
158+
SECTION_DATA_PROLOGUE(.data,,)
131159
{
132160
. = ALIGN(4);
133161
__data_start = .;
@@ -142,13 +170,14 @@ SECTIONS
142170
#include <snippets-ram-sections.ld>
143171
} GROUP_LINK_IN(RAMABLE_REGION)
144172

173+
/* Located in generated directory. This file is populated by the
174+
* zephyr_linker_sources() Cmake function.
175+
*/
145176
#include <snippets-data-sections.ld>
146177

147178
__data_end = .;
148179
__data_size = __data_end - __data_start;
149180

150-
#include <zephyr/linker/cplusplus-ram.ld>
151-
152181
SECTION_PROLOGUE(.got,,)
153182
{
154183
. = ALIGN(4);
@@ -173,7 +202,7 @@ SECTIONS
173202
*(.jcr)
174203
} GROUP_LINK_IN(RAMABLE_REGION)
175204

176-
SECTION_PROLOGUE(.sdata,,)
205+
SECTION_DATA_PROLOGUE(.sdata,,)
177206
{
178207
. = ALIGN(4);
179208
__sdata_start = .;
@@ -198,7 +227,7 @@ SECTIONS
198227
_gp = (__sbss_end + __sdata_start) / 2;
199228
PROVIDE(gp = _gp);
200229

201-
SECTION_PROLOGUE(.tdata,,)
230+
SECTION_DATA_PROLOGUE(.tdata,,)
202231
{
203232
. = ALIGN(4);
204233
__tdata_start = .;
@@ -243,14 +272,29 @@ SECTIONS
243272

244273
#include <snippets-sections.ld>
245274

246-
#include <zephyr/linker/debug-sections.ld>
247-
275+
/* Vitis Microblaze toolchain may moan without these sections,
276+
* but we won't give them any space. Zephyr creates its malloc arena
277+
* after _end. These are in case someone tries to use Vitis GCC with
278+
* its _HEAP_SIZE and _STACK_SIZE definitions. e.g. during migration
279+
* I'm making the linker moan so that you now know better than to rely
280+
* on those values in Zephyr world.
281+
*/
282+
_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? -_HEAP_SIZE : 0;
283+
_STACK_SIZE = DEFINED(_STACK_SIZE) ? -_STACK_SIZE : 0;
248284
SECTION_PROLOGUE(.heap (NOLOAD),,)
249285
{
250286
. += _HEAP_SIZE;
251-
. = ALIGN(4);
252287
} GROUP_LINK_IN(RAMABLE_REGION)
253288

254-
_end = .;
289+
SECTION_PROLOGUE(.stack (NOLOAD),,)
290+
{
291+
. += _STACK_SIZE;
292+
} GROUP_LINK_IN(RAMABLE_REGION)
293+
294+
#include <zephyr/linker/ram-end.ld>
295+
296+
GROUP_END(RAMABLE_REGION)
297+
298+
#include <zephyr/linker/debug-sections.ld>
255299

256300
}

0 commit comments

Comments
 (0)