blob: be636a542caead904675aff5ec0e451169f807e5 [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <sizes.h>
7
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +02008#if ((RMM_NUM_PAGES_PER_STACK == 0) || (GRANULE_SIZE == 0) || (MAX_CPUS== 0))
9#error "Required config options not set for the linker script."
10#endif
11
Soby Mathewb4c6df42022-11-09 11:13:29 +000012ENTRY(rmm_entry)
13
14MEMORY {
15 RAM (rwx): ORIGIN = 0x0, LENGTH = RMM_MAX_SIZE
16}
17
18SECTIONS
19{
20 rmm_base = .;
21
22 .text . : {
23 rmm_text_start = .;
24 *head.S.obj(.text*)
25 . = ALIGN(8);
26 *(.text*)
27 . = ALIGN(GRANULE_SIZE);
28 } >RAM
29
30 rmm_text_end = .;
31
32 ASSERT(rmm_text_end == ALIGN(GRANULE_SIZE), "rmm_text_end is not page aligned")
33
34 .rodata ALIGN(GRANULE_SIZE) : {
35 rmm_ro_start = .;
36 *(.rodata*)
37 . = ALIGN(8);
38 rmm_got_start = .;
39 *(.got)
40 rmm_got_end = .;
41 } >RAM
42
43 /*
44 * The xlat_static_table section is for full, aligned page tables.
45 * The static tables must not change once the MMU is enabled, so
46 * allocate them on the RO area to keep them protected from writing.
47 *
48 * The memory will be cleared by the xlat library during start up.
49 */
50 xlat_table ALIGN(GRANULE_SIZE) : {
51 *(xlat_static_tables)
52 } >RAM
53
54 rmm_ro_end = .;
55
56 ASSERT(rmm_ro_end == ALIGN(GRANULE_SIZE), "rmm_ro_end is not page aligned")
57
58 /* Align rw data to the next 2MB block */
59 .data ALIGN(SZ_2M) : {
60 rmm_rw_start = .;
61 *(.data*)
62 } >RAM
63
64 /*
65 * .rela.dyn needs to come after .data for the read-elf utility to
66 * parse this section correctly.
67 */
68 .rela.dyn ALIGN(8) : {
69 rmm_rela_start = .;
70 *(.rela*)
71 rmm_rela_end = .;
72 } >RAM
73
Soby Mathewb4c6df42022-11-09 11:13:29 +000074 .bss ALIGN(16) (NOLOAD) : {
75 bss_start = .;
76 *(.bss*)
77 bss_end = .;
78 } >RAM
79
Shanker Donthineniea0213a2025-01-12 09:28:12 -060080 .granules_memory ALIGN(GRANULE_SIZE) (NOLOAD) : {
81 granules_memory_start = .;
82 *(granules_memory)
83 . = ALIGN(GRANULE_SIZE);
84 granules_memory_end = .;
85 } >RAM
86
Javier Almansa Sobrinoed932592023-01-24 12:50:41 +000087 . = ALIGN(GRANULE_SIZE);
Soby Mathewb4c6df42022-11-09 11:13:29 +000088 rmm_rw_end = .;
Soby Mathewb4c6df42022-11-09 11:13:29 +000089
90 ASSERT(rmm_rw_end == ALIGN(GRANULE_SIZE), "rmm_rw_end is not page aligned")
91
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020092 .stack ALIGN(GRANULE_SIZE) (NOLOAD) : {
93 rmm_stack_start = .;
94 . = . + (RMM_NUM_PAGES_PER_STACK * GRANULE_SIZE * MAX_CPUS);
95 rmm_stack_end = .;
Mate Toth-Palc9f55e22023-08-14 09:45:45 +020096 rmm_eh_stack_start = .;
97 . = . + (GRANULE_SIZE * MAX_CPUS);
98 rmm_eh_stack_end = .;
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020099 } >RAM
100
101 rmm_end = .;
102
103 ASSERT(rmm_end == ALIGN(GRANULE_SIZE), "rmm_end is not page aligned")
104
Soby Mathewb4c6df42022-11-09 11:13:29 +0000105 /DISCARD/ : { *(.dynstr*) }
106 /DISCARD/ : { *(.dynsym*) }
107 /DISCARD/ : { *(.dynamic*) }
108 /DISCARD/ : { *(.hash*) }
109 /DISCARD/ : { *(.plt*) }
110 /DISCARD/ : { *(.interp*) }
111 /DISCARD/ : { *(.gnu*) }
112 /DISCARD/ : { *(.note*) }
113}