forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu_x86_tiny.ld
830 lines (634 loc) · 20.5 KB
/
qemu_x86_tiny.ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
/*
* Copyright (c) 2013-2014 Wind River Systems, Inc.
* Copyright (c) 2021 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/devicetree.h>
#include <offsets.h>
#include <zephyr/linker/linker-defs.h>
#include <zephyr/linker/linker-tool.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/mem_manage.h>
/* Bounds of physical RAM from DTS */
#define PHYS_RAM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_sram))
#define PHYS_RAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram))
/* Bounds of flash from DTS */
#define FLASH_ROM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_flash))
#define FLASH_ROM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_flash))
/* Virtual base address for the kernel; with CONFIG_MMU this is not necessarily
* the same as its physical location, although an identity mapping for RAM
* is still supported by setting CONFIG_KERNEL_VM_BASE=CONFIG_SRAM_BASE_ADDRESS.
*/
#ifdef Z_VM_KERNEL
#define KERNEL_BASE_ADDR \
(CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET)
#define KERNEL_RAM_SIZE \
(CONFIG_KERNEL_VM_SIZE - CONFIG_KERNEL_VM_OFFSET)
#define PHYS_RAM_AVAIL \
(PHYS_RAM_SIZE - CONFIG_SRAM_OFFSET)
#else
#define KERNEL_BASE_ADDR (PHYS_RAM_ADDR + CONFIG_SRAM_OFFSET)
#define KERNEL_RAM_SIZE (PHYS_RAM_SIZE - CONFIG_SRAM_OFFSET)
#endif
/* "kernel RAM" for linker VMA allocations starts at the offset */
/* Physical RAM location where the kernel image is loaded */
#define PHYS_LOAD_ADDR (PHYS_RAM_ADDR + CONFIG_SRAM_OFFSET)
#ifdef CONFIG_USERSPACE
#define SMEM_PARTITION_ALIGN(size) MMU_PAGE_ALIGN_PERM
#define APP_SHARED_ALIGN MMU_PAGE_ALIGN_PERM
#endif
MEMORY
{
#if defined(Z_VM_KERNEL)
ROM (rx) : ORIGIN = PHYS_LOAD_ADDR, LENGTH = PHYS_RAM_AVAIL
#endif
RAM (wx) : ORIGIN = KERNEL_BASE_ADDR, LENGTH = KERNEL_RAM_SIZE
#if defined(CONFIG_DEMAND_PAGING) && !defined(CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT)
FLASH (rw) : ORIGIN = FLASH_ROM_ADDR, LENGTH = FLASH_ROM_SIZE
#endif
/*
* On 32-bit x86, fake memory area for build-time IDT generation data.
*
* It doesn't matter where this region goes as it is stripped from the
* final ELF image. The address doesn't even have to be valid on the
* target. However, it shouldn't overlap any other regions.
*/
IDT_LIST : ORIGIN = 0xFFFF1000, LENGTH = 2K
}
#if defined(Z_VM_KERNEL)
#define ROMABLE_REGION ROM
#define RAMABLE_REGION RAM
#else
#define ROMABLE_REGION RAM
#define RAMABLE_REGION RAM
#endif
#ifdef CONFIG_MMU
#define MMU_PAGE_ALIGN . = ALIGN(CONFIG_MMU_PAGE_SIZE);
#else
#define MMU_PAGE_ALIGN
#endif
#if defined(CONFIG_DEMAND_PAGING) && !defined(CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT)
#undef SECTION_PROLOGUE
#define SECTION_PROLOGUE(name, options, align) \
name options : ALIGN_WITH_INPUT align
#undef SECTION_DATA_PROLOGUE
#define SECTION_DATA_PROLOGUE(name, options, align) \
name options : ALIGN_WITH_INPUT align
#undef GROUP_ROM_LINK_IN
#define GROUP_ROM_LINK_IN(vregion, lregion) > vregion AT > lregion
#undef GROUP_DATA_LINK_IN
#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion
#undef GROUP_NOLOAD_LINK_IN
#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion AT > lregion
#endif
/* Used to align areas with separate memory permission characteristics
* so that the page permissions can be set in the MMU. Without this,
* the kernel is just one blob with the same RWX permissions on all RAM
*/
#ifdef CONFIG_SRAM_REGION_PERMISSIONS
#define MMU_PAGE_ALIGN_PERM MMU_PAGE_ALIGN
#else
#define MMU_PAGE_ALIGN_PERM
#endif
/* For all source files under arch/x86/. */
#define LIB_ARCH_X86_IN_SECT(lsect) \
*libarch__x86__core.a.a:(.##lsect) \
*libarch__x86__core.a:(.##lsect##.*)
#ifdef CONFIG_MINIMAL_LIBC
/* For all source files under lib/libc/minimal/.
* These files includes, for example, math and string functions.
*/
#define LIB_C_IN_SECT(lsect) \
*liblib__libc__minimal.a:(.##lsect) \
*liblib__libc__minimal.a:(.##lsect##.*)
#endif /* CONFIG_MINIMAL_LIBC */
#ifdef CONFIG_NEWLIB_LIBC
/* For Newlib libc-hook.c. */
#define LIB_C_IN_SECT(lsect) \
*liblib__libc__newlib.a:libc-hooks.c.obj(.##lsect) \
*liblib__libc__newlib.a:libc-hooks.c.obj(.##lsect##.*)
#endif /* CONFIG_NEWLIB_LIBC */
#ifdef CONFIG_PICOLIBC
/* For Picolibc libc-hook.c. */
#define LIB_C_IN_SECT(lsect) \
*liblib__libc__picolibc.a:libc-hooks.c.obj(.##lsect) \
*liblib__libc__picolibc.a:libc-hooks.c.obj(.##lsect##.*)
#endif /* CONFIG_PICOLIBC */
/*
* For drivers that are usually used (e.g. serial)
*/
#define LIB_DRIVERS_IN_SECT(lsect) \
*libdrivers__serial.a:(.##lsect) \
*libdrivers__serial.a:(.##lsect##.*) \
*hpet.c.obj(.##lsect) \
*hpet.c.obj(.##lsect##.*) \
*intc_ioapic.c.obj(.##lsect) \
*intc_ioapic.c.obj(.##lsect##.*) \
*intc_loapic.c.obj(.##lsect) \
*intc_loapic.c.obj(.##lsect##.*) \
*intc_system_apic.c.obj(.##lsect) \
*intc_system_apic.c.obj(.##lsect##.*) \
*rand32_timer.c.obj(.##lsect) \
*rand32_timer.c.obj(.##lsect##.*) \
*uart_console.c.obj(.##lsect) \
*uart_console.c.obj(.##lsect##.*)
/* For all source files under kernel/. and kernel related files */
#define LIB_KERNEL_IN_SECT(lsect) \
*libkernel.a:(.##lsect) \
*libkernel.a:(.##lsect##.*) \
*libsubsys__demand_paging__*.a:(.##lsect) \
*libsubsys__demand_paging__*.a:(.##lsect##.*)
/* For particular file packaged in libzephyr.a. */
#define LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, objfile) \
*libzephyr.a:objfile.c.obj(.##lsect) \
*libzephyr.a:objfile.c.obj(.##lsect##.*)
/* For source files under lib/os/ with commonly used functions. */
#define LIB_ZEPHYR_IN_SECT(lsect) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, assert) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, bitarray) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, cbprintf_complete) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, cbprintf_nano) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, configs) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, coverage) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, heap) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, heap-validate) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, mutex) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, notify) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, printk) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, sem) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, stdout_console) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, sys_clock_init) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, rb) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, tracing_none) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, tracing_tracking) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, thread_entry) \
LIB_ZEPHYR_OBJECT_FILE_IN_SECT(lsect, work_q)
/*
* Catch all for all internal/external kernel functions
* as they are usually defined as "static inline" where
* they are attached to the source which uses them.
* Hence the need to specify them here so they can be pinned.
*/
#define ZEPHYR_KERNEL_FUNCS_IN_SECT \
*(.text.atomic_*) \
*(.text.k_*) \
*(.text.sys_*_bit) \
*(.text.sys_bitfield_*) \
*(.text.sys_clock_hw_cycles_per_sec) \
*(.text.sys_cache_*) \
*(.text.sys_dcache_*) \
*(.text.sys_icache_*) \
*(.text.sys_mutex_*) \
*(.text.sys_notify_*) \
*(.text.sys_dlist_*) \
*(.text.sys_slist_*) \
*(.text.sys_sflist_*) \
*(.text.sys_sfnode_*) \
*(.text.sys_io_*) \
*(.text.sys_in*) \
*(.text.sys_out*) \
*(.text.sys_read*) \
*(.text.sys_write*) \
*(.text.sys_get_be*) \
*(.text.sys_get_le*) \
*(.text.sys_put_be*) \
*(.text.sys_put_le*) \
*(.text.sys_mem_swap) \
*(.text.sys_memcpy_swap) \
*(.text.z_*)
/* For logging subsys */
#define LIB_SUBSYS_LOGGING_IN_SECT(lsect) \
*log_*.c.obj(.##lsect) \
*log_*.c.obj(.##lsect.*) \
*mpsc_pbuf.c.obj(.##lsect) \
*mpsc_pbuf.c.obj(.##lsect.*)
epoint = Z_MEM_PHYS_ADDR(CONFIG_KERNEL_ENTRY);
ENTRY(epoint)
/* SECTIONS definitions */
SECTIONS
{
#include <zephyr/linker/rel-sections.ld>
/DISCARD/ :
{
*(.plt)
}
/DISCARD/ :
{
*(.iplt)
}
#ifdef CONFIG_LINKER_USE_BOOT_SECTION
SECTION_PROLOGUE(boot.text,,)
{
#include <snippets-rom-start.ld>
MMU_PAGE_ALIGN
lnkr_boot_start = .;
z_mapped_start = .;
lnkr_boot_text_start = .;
KEEP(*(.boot_text.__start))
*(.boot_text)
*(.boot_text.*)
*(.text.k_mem_paging_backing_store_init)
*(.text.k_mem_paging_eviction_init)
MMU_PAGE_ALIGN_PERM
lnkr_boot_text_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(boot.rodata,,)
{
MMU_PAGE_ALIGN_PERM
lnkr_boot_rodata_start = .;
*(.boot_rodata)
*(.boot_rodata.*)
MMU_PAGE_ALIGN_PERM
lnkr_boot_rodata_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(boot.data,,)
{
MMU_PAGE_ALIGN_PERM
. = ALIGN(4);
lnkr_boot_data_start = .;
*(.boot_data)
*(.boot_data.*)
lnkr_boot_data_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(boot.bss, (NOLOAD),)
{
. = ALIGN(4);
lnkr_boot_bss_start = .;
*(.boot_bss)
*(.boot_bss.*)
lnkr_boot_bss_end = .;
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(boot.noinit, (NOLOAD),)
{
. = ALIGN(4);
lnkr_boot_noinit_start = .;
*(.boot_noinit)
*(.boot_noinit.*)
lnkr_boot_noinit_end = .;
MMU_PAGE_ALIGN
lnkr_boot_end = .;
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
lnkr_boot_text_size = lnkr_boot_text_end - lnkr_boot_text_start;
lnkr_boot_rodata_size = lnkr_boot_rodata_end - lnkr_boot_rodata_start;
lnkr_boot_data_size = lnkr_boot_data_end - lnkr_boot_data_start;
lnkr_boot_bss_size = lnkr_boot_bss_end - lnkr_boot_bss_start;
lnkr_boot_noinit_size = lnkr_boot_noinit_end - lnkr_boot_noinit_start;
#endif /* CONFIG_LINKER_USE_BOOT_SECTION */
#ifdef CONFIG_LINKER_USE_PINNED_SECTION
SECTION_PROLOGUE(pinned.text,,)
{
#ifndef CONFIG_LINKER_USE_BOOT_SECTION
#include <snippets-rom-start.ld>
#endif
MMU_PAGE_ALIGN
lnkr_pinned_start = .;
#ifndef CONFIG_LINKER_USE_BOOT_SECTION
z_mapped_start = .;
#endif
lnkr_pinned_text_start = .;
LIB_KERNEL_IN_SECT(text)
LIB_ARCH_X86_IN_SECT(text)
*(.text._OffsetAbsSyms)
*(.pinned_text)
*(.pinned_text.*)
LIB_ZEPHYR_IN_SECT(text)
LIB_C_IN_SECT(text)
LIB_DRIVERS_IN_SECT(text)
LIB_SUBSYS_LOGGING_IN_SECT(text)
*_divdi3.o(.text)
*_udivdi3.o(.text)
*_udivmoddi4.o(.text)
*_umoddi3.o(.text)
*_popcountsi2.o(.text)
*(.gnu.linkonce.t.exc_*)
*(.text.*.constprop)
*(.text.*.constprop.*)
#ifdef CONFIG_NEWLIB_LIBC
*libc.a:(.text)
*libc.a:(.text.*)
#endif /* CONFIG_NEWLIB_LIBC */
#ifdef CONFIG_COVERAGE
*(.text._sub_I_00100_0)
#endif
ZEPHYR_KERNEL_FUNCS_IN_SECT
#include <zephyr/linker/kobject-text.ld>
MMU_PAGE_ALIGN_PERM
lnkr_pinned_text_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
MMU_PAGE_ALIGN_PERM
lnkr_pinned_rodata_start = .;
#include <zephyr/linker/common-rom.ld>
#include <zephyr/linker/thread-local-storage.ld>
SECTION_PROLOGUE(pinned.rodata,,)
{
#include <zephyr/arch/x86/ia32/scripts/static_intr.ld>
LIB_KERNEL_IN_SECT(rodata)
LIB_ARCH_X86_IN_SECT(rodata)
*(.pinned_rodata)
*(.pinned_rodata.*)
LIB_ZEPHYR_IN_SECT(rodata)
LIB_C_IN_SECT(rodata)
LIB_DRIVERS_IN_SECT(rodata)
LIB_SUBSYS_LOGGING_IN_SECT(rodata)
/* Static strings */
*(.rodata.str*.*)
*(.rodata.*.str*.*)
#ifdef CONFIG_NEWLIB_LIBC
*libc.a:(.rodata)
*libc.a:(.rodata.*)
#endif /* CONFIG_NEWLIB_LIBC */
#include <snippets-rodata.ld>
#include <snippets-pinned-rodata.ld>
#include <zephyr/linker/kobject-rom.ld>
MMU_PAGE_ALIGN_PERM
lnkr_pinned_rodata_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
SECTION_PROLOGUE(pinned.data,,)
{
MMU_PAGE_ALIGN_PERM
lnkr_pinned_data_start = .;
. = ALIGN(4);
#include <zephyr/arch/x86/ia32/scripts/shared_kernel_pages.ld>
#include <zephyr/arch/x86/ia32/scripts/dynamic_intr.ld>
LIB_KERNEL_IN_SECT(data)
LIB_ARCH_X86_IN_SECT(data)
*(.pinned_data)
*(.pinned_data.*)
LIB_ZEPHYR_IN_SECT(data)
LIB_C_IN_SECT(data)
LIB_DRIVERS_IN_SECT(data)
LIB_SUBSYS_LOGGING_IN_SECT(data)
#ifdef CONFIG_COVERAGE
*(.data.__gcov_.*)
/*
* This is for the struct gcov_info for
* various functions.
*/
*(.data..LPBX*)
#endif
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#include <zephyr/linker/common-ram.ld>
#include <zephyr/arch/x86/pagetables.ld>
#include <zephyr/linker/kobject-data.ld>
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-pinned-data-sections.ld>
lnkr_pinned_data_end = .;
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-pinned-ram-sections.ld>
SECTION_PROLOGUE(pinned.bss, (NOLOAD),)
{
. = ALIGN(4);
lnkr_pinned_bss_start = .;
LIB_KERNEL_IN_SECT(bss)
LIB_ARCH_X86_IN_SECT(bss)
*(.pinned_bss)
*(.pinned_bss.*)
LIB_ZEPHYR_IN_SECT(bss)
LIB_C_IN_SECT(bss)
LIB_DRIVERS_IN_SECT(bss)
LIB_SUBSYS_LOGGING_IN_SECT(bss)
#ifdef CONFIG_COVERAGE
*(.bss.__gcov0.*)
#endif
lnkr_pinned_bss_end = .;
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#ifdef CONFIG_USERSPACE
/* PINNED APP SHARED MEMORY REGION */
#include <app_smem_pinned.ld>
_app_smem_pinned_size = _app_smem_pinned_end - _app_smem_pinned_start;
_app_smem_pinned_num_words = _app_smem_pinned_size >> 2;
#endif /* CONFIG_USERSPACE */
SECTION_PROLOGUE(pinned.noinit, (NOLOAD),)
{
. = ALIGN(4);
lnkr_pinned_noinit_start = .;
LIB_KERNEL_IN_SECT(noinit)
LIB_ARCH_X86_IN_SECT(noinit)
*(.pinned_noinit)
*(.pinned_noinit.*)
LIB_ZEPHYR_IN_SECT(noinit)
LIB_C_IN_SECT(noinit)
LIB_DRIVERS_IN_SECT(noinit)
LIB_SUBSYS_LOGGING_IN_SECT(noinit)
#ifdef CONFIG_ZTEST
/* For tests/kernel/mem_slab/ tests */
*(.noinit.*.k_mem_slab_buf_*)
/* For tests/kernel/mem_heap tests */
*(.noinit.*.kheap_buf_*)
/* Pin ztest_thread_stack.
* This must be done or else double fault
* may arise: testing exceptions while
* page fault for the ztest stack.
*/
*libsubsys__testsuite__ztest.a:(.noinit.*)
#endif
lnkr_pinned_noinit_end = .;
MMU_PAGE_ALIGN
lnkr_pinned_end = .;
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
lnkr_pinned_text_size = lnkr_pinned_text_end - lnkr_pinned_text_start;
lnkr_pinned_rodata_size = lnkr_pinned_rodata_end - lnkr_pinned_rodata_start;
lnkr_pinned_data_size = lnkr_pinned_data_end - lnkr_pinned_data_start;
lnkr_pinned_bss_size = lnkr_pinned_bss_end - lnkr_pinned_bss_start;
lnkr_pinned_noinit_size = lnkr_pinned_noinit_end - lnkr_pinned_noinit_start;
#endif /* CONFIG_LINKER_USE_PINNED_SECTION */
#if defined(CONFIG_DEMAND_PAGING) && !defined(CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT)
/* From now on, put symbols into FLASH */
#undef ROMABLE_REGION
#define ROMABLE_REGION FLASH
/* This is to align the following sections in flash
* to their corresponding virtual addresses.
* In other words, the offset from start of flash
* for these sections would be the same from start of
* their virtual addresses. This provides a simple and
* direct mapping from backing store.
*/
flash_load_offset :
{
. = FLASH_ROM_ADDR + (lnkr_pinned_end - KERNEL_BASE_ADDR);
} > FLASH AT > FLASH
#endif
GROUP_START(ROMABLE_REGION)
. = ALIGN(8);
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
{
__text_region_start = .;
#if !defined(CONFIG_LINKER_USE_BOOT_SECTION) || \
!defined(CONFIG_LINKER_USE_PINNED_SECTION)
z_mapped_start = .;
#endif
#if !defined(CONFIG_LINKER_USE_BOOT_SECTION) || \
!defined(CONFIG_LINKER_USE_PINNED_SECTION)
/* Located in generated directory. This file is populated by calling
* zephyr_linker_sources(ROM_START ...). This typically contains the vector
* table and debug information.
*/
#include <snippets-rom-start.ld>
#endif
/* Needs KEEP() as ENTRY() is given a physical address */
KEEP(*(.text.__start))
*(.text)
*(".text.*")
*(.gnu.linkonce.t.*)
*(.init)
*(.fini)
*(.eini)
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/linker/kobject-text.ld>
#endif
MMU_PAGE_ALIGN_PERM
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
__text_region_end = .;
__text_region_size = __text_region_end - __text_region_start;
__rodata_region_start = .;
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/linker/common-rom.ld>
#include <zephyr/linker/thread-local-storage.ld>
#endif
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
{
*(.rodata)
*(".rodata.*")
*(.gnu.linkonce.r.*)
#ifndef CONFIG_DYNAMIC_INTERRUPTS
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/arch/x86/ia32/scripts/static_intr.ld>
#endif /* !CONFIG_LINKER_USE_PINNED_SECTION */
#endif /* CONFIG_DYNAMIC_INTERRUPTS */
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-rodata.ld>
#include <zephyr/linker/kobject-rom.ld>
#endif
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#include <zephyr/linker/cplusplus-rom.ld>
MMU_PAGE_ALIGN_PERM
/* ROM ends here, position counter will now be in RAM areas */
__rodata_region_end = .;
__rodata_region_size = __rodata_region_end - __rodata_region_start;
GROUP_END(ROMABLE_REGION)
/*
* Needed for dynamic linking which we do not have, do discard
*/
/DISCARD/ : {
*(.got.plt)
*(.igot.plt)
*(.got)
*(.igot)
}
/* RAMABLE_REGION */
GROUP_START(RAMABLE_REGION)
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-ram-sections.ld>
#ifdef CONFIG_USERSPACE
/* APP SHARED MEMORY REGION */
#include <app_smem.ld>
_image_ram_start = _app_smem_start;
_app_smem_size = _app_smem_end - _app_smem_start;
_app_smem_num_words = _app_smem_size >> 2;
_app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME);
#endif /* CONFIG_USERSPACE */
SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD),)
{
MMU_PAGE_ALIGN_PERM
#if !defined(CONFIG_USERSPACE)
_image_ram_start = .;
#endif
/*
* For performance, BSS section is forced to be both 4 byte aligned and
* a multiple of 4 bytes.
*/
. = ALIGN(4);
__kernel_ram_start = .;
__bss_start = .;
*(.bss)
*(".bss.*")
*(COMMON)
*(".kernel_bss.*")
/*
* As memory is cleared in words only, it is simpler to ensure the BSS
* section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
*/
. = ALIGN(4);
__bss_end = .;
} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
__bss_num_words = (__bss_end - __bss_start) >> 2;
#include <zephyr/linker/common-noinit.ld>
MMU_PAGE_ALIGN_PERM
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
{
__data_ram_start = .;
*(.data)
*(".data.*")
*(".kernel.*")
#ifdef CONFIG_DYNAMIC_INTERRUPTS
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/arch/x86/ia32/scripts/dynamic_intr.ld>
#endif /* !CONFIG_LINKER_USE_PINNED_SECTION */
#endif /* CONFIG_DYNAMIC_INTERRUPTS */
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-rwdata.ld>
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/arch/x86/ia32/scripts/shared_kernel_pages.ld>
#endif /* !CONFIG_LINKER_USE_PINNED_SECTION */
. = ALIGN(4);
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
__data_rom_start = LOADADDR(_DATA_SECTION_NAME);
#include <zephyr/linker/cplusplus-ram.ld>
#ifndef CONFIG_LINKER_USE_PINNED_SECTION
#include <zephyr/linker/common-ram.ld>
#include <zephyr/arch/x86/pagetables.ld>
/* Must be last in RAM */
#include <zephyr/linker/kobject-data.ld>
#endif /* !CONFIG_LINKER_USE_PINNED_SECTION */
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-data-sections.ld>
MMU_PAGE_ALIGN
__data_ram_end = .;
/* All unused memory also owned by the kernel for heaps */
__kernel_ram_end = KERNEL_BASE_ADDR + KERNEL_RAM_SIZE;
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
_image_ram_end = .;
_image_ram_all = (KERNEL_BASE_ADDR + KERNEL_RAM_SIZE) - _image_ram_start;
z_mapped_end = .;
z_mapped_size = z_mapped_end - z_mapped_start;
_end = .; /* end of image */
GROUP_END(RAMABLE_REGION)
#ifndef LINKER_ZEPHYR_FINAL
/* static interrupts */
SECTION_PROLOGUE(intList,,)
{
KEEP(*(.spurIsr))
KEEP(*(.spurNoErrIsr))
KEEP(*(.intList))
KEEP(*(.gnu.linkonce.intList.*))
} > IDT_LIST
#else
/DISCARD/ :
{
KEEP(*(.spurIsr))
KEEP(*(.spurNoErrIsr))
KEEP(*(.intList))
KEEP(*(.gnu.linkonce.intList.*))
}
#endif
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function.
*/
#include <snippets-sections.ld>
#include <zephyr/linker/debug-sections.ld>
/DISCARD/ : { *(.note.GNU-stack) }
}