blob: 03a737f69752a7d4547e6774b6856432ffde956a [file] [log] [blame]
developer550bf5e2016-07-11 16:05:23 +08001/*
Masahiro Yamada0b67e562020-03-09 17:39:48 +09002 * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
developer550bf5e2016-07-11 16:05:23 +08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
developer550bf5e2016-07-11 16:05:23 +08005 */
6
Masahiro Yamada0b67e562020-03-09 17:39:48 +09007#include <common/bl_common.ld.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <lib/xlat_tables/xlat_tables_defs.h>
developer550bf5e2016-07-11 16:05:23 +08009
10OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
11OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
12ENTRY(bl31_entrypoint)
13
14
15MEMORY {
16 RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_TZRAM_SIZE
17 RAM2 (rwx): ORIGIN = TZRAM2_BASE, LENGTH = TZRAM2_SIZE
18}
19
20
21SECTIONS
22{
23 . = BL31_BASE;
24
25 ASSERT(. == ALIGN(2048),
26 "vector base is not aligned on a 2K boundary.")
27
28 __RO_START__ = .;
29 vector . : {
30 *(.vectors)
31 } >RAM
32
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000033 ASSERT(. == ALIGN(PAGE_SIZE),
developer550bf5e2016-07-11 16:05:23 +080034 "BL31_BASE address is not aligned on a page boundary.")
35
36 ro . : {
37 *bl31_entrypoint.o(.text*)
38 *(.text*)
39 *(.rodata*)
40
Masahiro Yamadaac1bfb92020-03-26 10:51:39 +090041 RT_SVC_DESCS
42 CPU_OPS
developer550bf5e2016-07-11 16:05:23 +080043
44 __RO_END_UNALIGNED__ = .;
45 /*
46 * Memory page(s) mapped to this section will be marked as read-only,
47 * executable. No RW data from the next section must creep in.
48 * Ensure the rest of the current memory page is unused.
49 */
Roberto Vargasd93fde32018-04-11 11:53:31 +010050 . = ALIGN(PAGE_SIZE);
developer550bf5e2016-07-11 16:05:23 +080051 __RO_END__ = .;
52 } >RAM
53
54 ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
55 "cpu_ops not defined for this platform.")
56
57 /*
58 * Define a linker symbol to mark start of the RW memory area for this
59 * image.
60 */
61 __RW_START__ = . ;
62
Douglas Raillard306593d2017-02-24 18:14:15 +000063 /*
64 * .data must be placed at a lower address than the stacks if the stack
65 * protector is enabled. Alternatively, the .data.stack_protector_canary
66 * section can be placed independently of the main .data section.
67 */
developer550bf5e2016-07-11 16:05:23 +080068 .data . : {
69 __DATA_START__ = .;
70 *(.data*)
71 __DATA_END__ = .;
72 } >RAM
73
74#ifdef BL31_PROGBITS_LIMIT
75 ASSERT(. <= BL31_PROGBITS_LIMIT, "BL3-1 progbits has exceeded its limit.")
76#endif
77
78 stacks (NOLOAD) : {
79 __STACKS_START__ = .;
80 *(tzfw_normal_stacks)
81 __STACKS_END__ = .;
82 } >RAM
83
84 /*
85 * The .bss section gets initialised to 0 at runtime.
Douglas Raillard21362a92016-12-02 13:51:54 +000086 * Its base address should be 16-byte aligned for better performance of the
87 * zero-initialization code.
developer550bf5e2016-07-11 16:05:23 +080088 */
89 .bss (NOLOAD) : ALIGN(16) {
90 __BSS_START__ = .;
91 *(.bss*)
92 *(COMMON)
Masahiro Yamadaac1bfb92020-03-26 10:51:39 +090093 BAKERY_LOCK_NORMAL
developer550bf5e2016-07-11 16:05:23 +080094 __BSS_END__ = .;
95 __RW_END__ = .;
96 } >RAM
97
98 ASSERT(. <= BL31_LIMIT, "BL3-1 image has exceeded its limit.")
99
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900100 XLAT_TABLE_SECTION >RAM2
developer550bf5e2016-07-11 16:05:23 +0800101
102#if USE_COHERENT_MEM
103 /*
104 * The base address of the coherent memory section must be page-aligned (4K)
105 * to guarantee that the coherent data are stored on their own pages and
106 * are not mixed with normal data. This is required to set up the correct
107 * memory attributes for the coherent data page tables.
108 */
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000109 coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
developer550bf5e2016-07-11 16:05:23 +0800110 __COHERENT_RAM_START__ = .;
111 /*
112 * Bakery locks are stored in coherent memory
113 *
114 * Each lock's data is contiguous and fully allocated by the compiler
115 */
116 *(bakery_lock)
117 *(tzfw_coherent_mem)
118 __COHERENT_RAM_END_UNALIGNED__ = .;
119 /*
120 * Memory page(s) mapped to this section will be marked
121 * as device memory. No other unexpected data must creep in.
122 * Ensure the rest of the current memory page is unused.
123 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100124 . = ALIGN(PAGE_SIZE);
developer550bf5e2016-07-11 16:05:23 +0800125 __COHERENT_RAM_END__ = .;
126 } >RAM2
127#endif
128
129 /*
130 * Define a linker symbol to mark end of the RW memory area for this
131 * image.
132 */
133 __BL31_END__ = .;
134
135 __BSS_SIZE__ = SIZEOF(.bss);
136#if USE_COHERENT_MEM
137 __COHERENT_RAM_UNALIGNED_SIZE__ =
138 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
139#endif
140
141 ASSERT(. <= TZRAM2_LIMIT, "TZRAM2 image has exceeded its limit.")
142}