2 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
7 #include <platform_def.h>
8 #include <xlat_tables_defs.h>
10 OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
11 OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
12 ENTRY(bl31_entrypoint)
16 RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE
19 #ifdef PLAT_EXTRA_LD_SCRIPT
26 ASSERT(. == ALIGN(PAGE_SIZE),
27 "BL31_BASE address is not aligned on a page boundary.")
29 #if SEPARATE_CODE_AND_RODATA
32 *bl31_entrypoint.o(.text*)
43 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
45 __RT_SVC_DESCS_START__ = .;
47 __RT_SVC_DESCS_END__ = .;
50 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
52 __PMF_SVC_DESCS_START__ = .;
53 KEEP(*(pmf_svc_descs))
54 __PMF_SVC_DESCS_END__ = .;
55 #endif /* ENABLE_PMF */
58 * Ensure 8-byte alignment for cpu_ops so that its fields are also
59 * aligned. Also ensure cpu_ops inclusion.
62 __CPU_OPS_START__ = .;
66 /* Place pubsub sections for events */
68 #include <pubsub_events.h>
76 *bl31_entrypoint.o(.text*)
80 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
82 __RT_SVC_DESCS_START__ = .;
84 __RT_SVC_DESCS_END__ = .;
87 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
89 __PMF_SVC_DESCS_START__ = .;
90 KEEP(*(pmf_svc_descs))
91 __PMF_SVC_DESCS_END__ = .;
92 #endif /* ENABLE_PMF */
95 * Ensure 8-byte alignment for cpu_ops so that its fields are also
96 * aligned. Also ensure cpu_ops inclusion.
99 __CPU_OPS_START__ = .;
103 /* Place pubsub sections for events */
105 #include <pubsub_events.h>
108 __RO_END_UNALIGNED__ = .;
110 * Memory page(s) mapped to this section will be marked as read-only,
111 * executable. No RW data from the next section must creep in.
112 * Ensure the rest of the current memory page is unused.
114 . = ALIGN(PAGE_SIZE);
119 ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
120 "cpu_ops not defined for this platform.")
124 * Exception vectors of the SPM shim layer. They must be aligned to a 2K
125 * address, but we need to place them in a separate page so that we can set
126 * individual permissions to them, so the actual alignment needed is 4K.
128 * There's no need to include this into the RO section of BL31 because it
129 * doesn't need to be accessed by BL31.
131 spm_shim_exceptions : ALIGN(PAGE_SIZE) {
132 __SPM_SHIM_EXCEPTIONS_START__ = .;
133 *(.spm_shim_exceptions)
134 . = ALIGN(PAGE_SIZE);
135 __SPM_SHIM_EXCEPTIONS_END__ = .;
140 * Define a linker symbol to mark start of the RW memory area for this
146 * .data must be placed at a lower address than the stacks if the stack
147 * protector is enabled. Alternatively, the .data.stack_protector_canary
148 * section can be placed independently of the main .data section.
156 #ifdef BL31_PROGBITS_LIMIT
157 ASSERT(. <= BL31_PROGBITS_LIMIT, "BL31 progbits has exceeded its limit.")
161 __STACKS_START__ = .;
162 *(tzfw_normal_stacks)
167 * The .bss section gets initialised to 0 at runtime.
168 * Its base address should be 16-byte aligned for better performance of the
169 * zero-initialization code.
171 .bss (NOLOAD) : ALIGN(16) {
175 #if !USE_COHERENT_MEM
177 * Bakery locks are stored in normal .bss memory
179 * Each lock's data is spread across multiple cache lines, one per CPU,
180 * but multiple locks can share the same cache line.
181 * The compiler will allocate enough memory for one CPU's bakery locks,
182 * the remaining cache lines are allocated by the linker script
184 . = ALIGN(CACHE_WRITEBACK_GRANULE);
185 __BAKERY_LOCK_START__ = .;
187 . = ALIGN(CACHE_WRITEBACK_GRANULE);
188 __PERCPU_BAKERY_LOCK_SIZE__ = ABSOLUTE(. - __BAKERY_LOCK_START__);
189 . = . + (__PERCPU_BAKERY_LOCK_SIZE__ * (PLATFORM_CORE_COUNT - 1));
190 __BAKERY_LOCK_END__ = .;
191 #ifdef PLAT_PERCPU_BAKERY_LOCK_SIZE
192 ASSERT(__PERCPU_BAKERY_LOCK_SIZE__ == PLAT_PERCPU_BAKERY_LOCK_SIZE,
193 "PLAT_PERCPU_BAKERY_LOCK_SIZE does not match bakery lock requirements");
199 * Time-stamps are stored in normal .bss memory
201 * The compiler will allocate enough memory for one CPU's time-stamps,
202 * the remaining memory for other CPU's is allocated by the
205 . = ALIGN(CACHE_WRITEBACK_GRANULE);
206 __PMF_TIMESTAMP_START__ = .;
207 KEEP(*(pmf_timestamp_array))
208 . = ALIGN(CACHE_WRITEBACK_GRANULE);
209 __PMF_PERCPU_TIMESTAMP_END__ = .;
210 __PERCPU_TIMESTAMP_SIZE__ = ABSOLUTE(. - __PMF_TIMESTAMP_START__);
211 . = . + (__PERCPU_TIMESTAMP_SIZE__ * (PLATFORM_CORE_COUNT - 1));
212 __PMF_TIMESTAMP_END__ = .;
213 #endif /* ENABLE_PMF */
218 * The xlat_table section is for full, aligned page tables (4K).
219 * Removing them from .bss avoids forcing 4K alignment on
220 * the .bss section. The tables are initialized to zero by the translation
223 xlat_table (NOLOAD) : {
229 * The base address of the coherent memory section must be page-aligned (4K)
230 * to guarantee that the coherent data are stored on their own pages and
231 * are not mixed with normal data. This is required to set up the correct
232 * memory attributes for the coherent data page tables.
234 coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
235 __COHERENT_RAM_START__ = .;
237 * Bakery locks are stored in coherent memory
239 * Each lock's data is contiguous and fully allocated by the compiler
243 __COHERENT_RAM_END_UNALIGNED__ = .;
245 * Memory page(s) mapped to this section will be marked
246 * as device memory. No other unexpected data must creep in.
247 * Ensure the rest of the current memory page is unused.
249 . = ALIGN(PAGE_SIZE);
250 __COHERENT_RAM_END__ = .;
255 * Define a linker symbol to mark end of the RW memory area for this
261 __BSS_SIZE__ = SIZEOF(.bss);
263 __COHERENT_RAM_UNALIGNED_SIZE__ =
264 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
267 ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.")