20
20
#include <zephyr/linker/linker-tool.h>
21
21
22
22
#define RAMABLE_REGION RAM :sram0_phdr
23
- #define ROMABLE_REGION rom0_seg :rom0_phdr
23
+ #define ROMABLE_REGION RAM :sram0_phdr
24
24
25
25
#ifdef CONFIG_MMU
26
26
#define MMU_PAGE_ALIGN . = ALIGN (CONFIG_MMU_PAGE_SIZE);
@@ -287,6 +287,9 @@ SECTIONS
287
287
_DoubleExceptionVector_text_end = ABSOLUTE (.);
288
288
} >sram0_18_seg :sram0_18_phdr
289
289
290
+ #define LIB_OBJ_FUNC_IN_SECT(library, obj_file, func) \
291
+ *##library## :##obj_file##(.literal.##func .text.##func) \
292
+
290
293
#ifdef CONFIG_XTENSA_MMU
291
294
.vec_helpers :
292
295
{
@@ -301,48 +304,45 @@ SECTIONS
301
304
* TLB multi-hit exception.
302
305
*/
303
306
304
- *libarch__xtensa__core.a :xtensa-asm2-util.S.obj(.literal)
305
- *libarch__xtensa__core.a :xtensa-asm2-util.S.obj(.text)
306
- *libarch__xtensa__core.a :xtensa-asm2-util.S.obj(.iram.text)
307
- *libarch__xtensa__core.a :xtensa-asm2-util.S.obj(.iram0.text)
307
+ *libarch__xtensa__core.a :xtensa-asm2-util.S.obj(.literal .text)
308
+ *libarch__xtensa__core.a :xtensa-asm2-util.S.obj(.iram.text .iram0.text)
308
309
309
310
*libarch__xtensa__core.a :window_vectors.S.obj(.iram.text)
310
311
311
- *libarch__xtensa__core.a :xtensa-asm2.c.obj(.literal.*)
312
- *libarch__xtensa__core.a :xtensa-asm2.c.obj(.text.*)
313
-
314
- *libarch__xtensa__core.a :fatal.c.obj(.literal.*)
315
- *libarch__xtensa__core.a :fatal.c.obj(.text.*)
316
-
317
- *libarch__xtensa__core.a :crt1.S.obj(.literal)
318
- *libarch__xtensa__core.a :crt1.S.obj(.text)
312
+ *libarch__xtensa__core.a :crt1.S.obj(.literal .text)
319
313
320
- *libarch__xtensa__core.a :cpu_idle.c.obj(.literal.*)
321
- *libarch__xtensa__core.a :cpu_idle.c.obj(.text.*)
314
+ LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,xtensa-asm2.c.obj,*)
315
+ LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,fatal.c.obj,*)
316
+ LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,cpu_idle.c.obj,*)
322
317
323
318
*(.text.arch_is_in_isr)
324
319
325
320
/* To support backtracing */
326
- *libarch__xtensa__core.a :xtensa_backtrace.c.obj(.literal.*)
327
- *libarch__xtensa__core.a :xtensa_backtrace.c.obj(.text.*)
328
- *libarch__xtensa__core.a :debug_helpers_asm.S.obj(.iram1.literal)
329
- *libarch__xtensa__core.a :debug_helpers_asm.S.obj(.iram1)
321
+ LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,xtensa_backtrace.c.obj,*)
330
322
331
- *libkernel.a :fatal.c.obj(.literal.*)
332
- *libkernel.a :fatal.c.obj(.text.*)
323
+ *libarch__xtensa__core.a :debug_helpers_asm.S.obj(.iram1.literal .iram1)
324
+
325
+ /* Userspace related stuff */
326
+ LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,userspace.S.obj,z_xtensa_do_syscall)
327
+ LIB_OBJ_FUNC_IN_SECT(libarch__xtensa__core.a,xtensa_mmu.c.obj,z_xtensa_swap_update_page_tables)
333
328
334
329
/* Below are to speed up execution by avoiding TLB misses
335
330
* on frequently used functions.
331
+ *
332
+ * There is almost 1MB space (due to TLB pinning) so we can
333
+ * be generous.
336
334
*/
337
- *libkernel.a :sched.c.obj(.literal.*)
338
- *libkernel.a :sched.c.obj(.text.*)
339
- *libkernel.a :timeout.c.obj(.literal.*)
340
- *libkernel.a :timeout.c.obj(.text.*)
341
-
342
- *libdrivers__console.a :(.literal.*)
343
- *libdrivers__console.a :(.text.*)
344
- *libdrivers__timer.a :(.literal.*)
345
- *libdrivers__timer.a :(.text.*)
335
+ LIB_OBJ_FUNC_IN_SECT(libkernel.a,,*)
336
+
337
+ LIB_OBJ_FUNC_IN_SECT(libdrivers__console.a,,*)
338
+ LIB_OBJ_FUNC_IN_SECT(libdrivers__timer.a,,*)
339
+
340
+ *(.literal.z_vrfy_* .text.z_vrfy_*)
341
+ *(.literal.z_mrsh_* .text.z_mrsh_*)
342
+ *(.literal.z_impl_* .text.z_impl_*)
343
+ *(.literal.z_obj_* .text.z_obj_*)
344
+
345
+ *(.literal.k_sys_fatal_error_handler .text.k_sys_fatal_error_handler)
346
346
} >vec_helpers :vec_helpers_phdr
347
347
#endif /* CONFIG_XTENSA_MMU */
348
348
@@ -380,7 +380,7 @@ SECTIONS
380
380
381
381
_text_end = ABSOLUTE (.);
382
382
_etext = .;
383
- } >RAM :sram0_phdr
383
+ } >RAMABLE_REGION
384
384
__text_region_end = .;
385
385
386
386
.rodata : HDR_MMU_PAGE_ALIGN
@@ -394,7 +394,16 @@ SECTIONS
394
394
. = ALIGN (4);
395
395
#include <snippets-rodata.ld>
396
396
#include <zephyr/linker/kobject-rom.ld>
397
+ } >RAMABLE_REGION
398
+
399
+ #include <zephyr/linker/common-rom.ld>
400
+
401
+ #include <zephyr/linker/thread-local-storage.ld>
397
402
403
+ #include <zephyr/linker/cplusplus-rom.ld>
404
+
405
+ .rodata_end : ALIGN (4)
406
+ {
398
407
. = ALIGN (4); /* this table MUST be 4-byte aligned */
399
408
_bss_table_start = ABSOLUTE (.);
400
409
LONG (_bss_start )
@@ -404,19 +413,26 @@ SECTIONS
404
413
MMU_PAGE_ALIGN
405
414
406
415
__rodata_region_end = ABSOLUTE (.);
407
- } >RAM :sram0_phdr
416
+ } >RAMABLE_REGION
408
417
409
- #include <zephyr/linker/common-rom.ld>
418
+ #ifdef CONFIG_USERSPACE
419
+ #define SMEM_PARTITION_ALIGN(size) MMU_PAGE_ALIGN
420
+ #define APP_SHARED_ALIGN MMU_PAGE_ALIGN
410
421
411
- #include <zephyr/linker/thread-local-storage .ld>
422
+ #include <app_smem .ld>
412
423
413
- #include <zephyr/linker/cplusplus-rom.ld>
414
-
415
- #include <snippets-sections.ld>
424
+ _image_ram_start = _app_smem_start;
425
+ _app_smem_size = _app_smem_end - _app_smem_start;
426
+ _app_smem_num_words = _app_smem_size >> 2;
427
+ _app_smem_rom_start = LOADADDR (_APP_SMEM_SECTION_NAME);
428
+ _app_smem_num_words = _app_smem_size >> 2;
429
+ #endif /* CONFIG_USERSPACE */
416
430
417
431
.data : HDR_MMU_PAGE_ALIGN
418
432
{
433
+ #ifndef CONFIG_USERSPACE
419
434
_image_ram_start = ABSOLUTE (.);
435
+ #endif
420
436
__data_start = ABSOLUTE (.);
421
437
*(.data)
422
438
*(.data.*)
@@ -438,7 +454,9 @@ SECTIONS
438
454
MMU_PAGE_ALIGN
439
455
440
456
__data_end = ABSOLUTE (.);
441
- } >RAM :sram0_phdr
457
+ } >RAMABLE_REGION
458
+
459
+ #include <snippets-sections.ld>
442
460
443
461
#include <snippets-data-sections.ld>
444
462
0 commit comments