blob: 77a914b605532f86e9f2f49dfa463982a8a668a5 [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
Javier Almansa Sobrinoed932592023-01-24 12:50:41 +000080 . = ALIGN(GRANULE_SIZE);
Soby Mathewb4c6df42022-11-09 11:13:29 +000081 rmm_rw_end = .;
Soby Mathewb4c6df42022-11-09 11:13:29 +000082
83 ASSERT(rmm_rw_end == ALIGN(GRANULE_SIZE), "rmm_rw_end is not page aligned")
84
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020085 .stack ALIGN(GRANULE_SIZE) (NOLOAD) : {
86 rmm_stack_start = .;
87 . = . + (RMM_NUM_PAGES_PER_STACK * GRANULE_SIZE * MAX_CPUS);
88 rmm_stack_end = .;
Mate Toth-Palc9f55e22023-08-14 09:45:45 +020089 rmm_eh_stack_start = .;
90 . = . + (GRANULE_SIZE * MAX_CPUS);
91 rmm_eh_stack_end = .;
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +020092 } >RAM
93
94 rmm_end = .;
95
96 ASSERT(rmm_end == ALIGN(GRANULE_SIZE), "rmm_end is not page aligned")
97
Soby Mathewb4c6df42022-11-09 11:13:29 +000098 /DISCARD/ : { *(.dynstr*) }
99 /DISCARD/ : { *(.dynsym*) }
100 /DISCARD/ : { *(.dynamic*) }
101 /DISCARD/ : { *(.hash*) }
102 /DISCARD/ : { *(.plt*) }
103 /DISCARD/ : { *(.interp*) }
104 /DISCARD/ : { *(.gnu*) }
105 /DISCARD/ : { *(.note*) }
106}