blob: 5d3139b60dcecf9b00a79ee0794ca0414e4268fe [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Madhukar Pappireddyf4e6ea62020-01-27 15:32:15 -06002 * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
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>
Achin Gupta4f6ad662013-10-25 09:08:21 +01009
10OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
11OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
Jeenu Viswambharan2a30a752014-03-11 11:06:45 +000012ENTRY(bl31_entrypoint)
Achin Gupta4f6ad662013-10-25 09:08:21 +010013
Achin Gupta4f6ad662013-10-25 09:08:21 +010014MEMORY {
Juan Castillofd8c0772014-09-16 10:40:35 +010015 RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE
Chris Kay4b7660a2022-09-29 14:36:53 +010016
Samuel Holland31a14e12018-10-17 21:40:18 -050017#if SEPARATE_NOBITS_REGION
18 NOBITS (rw!a): ORIGIN = BL31_NOBITS_BASE, LENGTH = BL31_NOBITS_LIMIT - BL31_NOBITS_BASE
Chris Kay4b7660a2022-09-29 14:36:53 +010019#else /* SEPARATE_NOBITS_REGION */
20# define NOBITS RAM
21#endif /* SEPARATE_NOBITS_REGION */
Achin Gupta4f6ad662013-10-25 09:08:21 +010022}
23
Caesar Wangd90f43e2016-10-11 09:36:00 +080024#ifdef PLAT_EXTRA_LD_SCRIPT
Chris Kay4b7660a2022-09-29 14:36:53 +010025# include <plat.ld.S>
26#endif /* PLAT_EXTRA_LD_SCRIPT */
Achin Gupta4f6ad662013-10-25 09:08:21 +010027
Chris Kay4b7660a2022-09-29 14:36:53 +010028SECTIONS {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000029 . = BL31_BASE;
Chris Kay4b7660a2022-09-29 14:36:53 +010030
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000031 ASSERT(. == ALIGN(PAGE_SIZE),
Chris Kay4b7660a2022-09-29 14:36:53 +010032 "BL31_BASE address is not aligned on a page boundary.")
Achin Gupta4f6ad662013-10-25 09:08:21 +010033
Soby Mathew4e28c202018-10-14 08:09:22 +010034 __BL31_START__ = .;
35
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010036#if SEPARATE_CODE_AND_RODATA
37 .text . : {
38 __TEXT_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010039
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010040 *bl31_entrypoint.o(.text*)
Jimmy Brissoned202072020-08-04 16:18:52 -050041 *(SORT_BY_ALIGNMENT(SORT(.text*)))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010042 *(.vectors)
Chris Kay4b7660a2022-09-29 14:36:53 +010043
Roberto Vargasd93fde32018-04-11 11:53:31 +010044 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010045
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010046 __TEXT_END__ = .;
47 } >RAM
48
49 .rodata . : {
50 __RODATA_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010051
Samuel Holland23f5e542019-10-20 16:11:25 -050052 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010053
Chris Kay4b7660a2022-09-29 14:36:53 +010054# if PLAT_EXTRA_RODATA_INCLUDES
55# include <plat.ld.rodata.inc>
56# endif /* PLAT_EXTRA_RODATA_INCLUDES */
developer8a3180d2022-08-05 10:04:10 +080057
Chris Kay4b7660a2022-09-29 14:36:53 +010058 RODATA_COMMON
Soby Mathew4e28c202018-10-14 08:09:22 +010059
Jeenu Viswambharane3f22002017-09-22 08:32:10 +010060 . = ALIGN(8);
Chris Kay4b7660a2022-09-29 14:36:53 +010061
62# include <lib/el3_runtime/pubsub_events.h>
Jeenu Viswambharane3f22002017-09-22 08:32:10 +010063
Roberto Vargasd93fde32018-04-11 11:53:31 +010064 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010065
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010066 __RODATA_END__ = .;
67 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +010068#else /* SEPARATE_CODE_AND_RODATA */
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000069 ro . : {
70 __RO_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010071
Andrew Thoelkee01ea342014-03-18 07:13:52 +000072 *bl31_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050073 *(SORT_BY_ALIGNMENT(.text*))
74 *(SORT_BY_ALIGNMENT(.rodata*))
Achin Gupta7421b462014-02-01 18:53:26 +000075
Chris Kay4b7660a2022-09-29 14:36:53 +010076 RODATA_COMMON
Soby Mathew2b3fc1d2018-12-12 14:33:11 +000077
Jeenu Viswambharane3f22002017-09-22 08:32:10 +010078 . = ALIGN(8);
Chris Kay4b7660a2022-09-29 14:36:53 +010079
80# include <lib/el3_runtime/pubsub_events.h>
Jeenu Viswambharane3f22002017-09-22 08:32:10 +010081
Achin Guptab739f222014-01-18 16:50:09 +000082 *(.vectors)
Chris Kay4b7660a2022-09-29 14:36:53 +010083
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000084 __RO_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010085
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000086 /*
87 * Memory page(s) mapped to this section will be marked as read-only,
Chris Kay4b7660a2022-09-29 14:36:53 +010088 * executable. No RW data from the next section must creep in. Ensure
89 * that the rest of the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000090 */
Roberto Vargasd93fde32018-04-11 11:53:31 +010091 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010092
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000093 __RO_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +010094 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +010095#endif /* SEPARATE_CODE_AND_RODATA */
Achin Gupta4f6ad662013-10-25 09:08:21 +010096
Soby Mathewc704cbc2014-08-14 11:33:56 +010097 ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
Chris Kay4b7660a2022-09-29 14:36:53 +010098 "cpu_ops not defined for this platform.")
Soby Mathewc704cbc2014-08-14 11:33:56 +010099
Paul Beesleydb4e25a2019-10-14 15:27:12 +0000100#if SPM_MM
Chris Kay4b7660a2022-09-29 14:36:53 +0100101# ifndef SPM_SHIM_EXCEPTIONS_VMA
102# define SPM_SHIM_EXCEPTIONS_VMA RAM
103# endif /* SPM_SHIM_EXCEPTIONS_VMA */
Ard Biesheuvel447d56f2019-01-06 10:07:24 +0100104
Antonio Nino Diazc41f2062017-10-24 10:07:35 +0100105 /*
106 * Exception vectors of the SPM shim layer. They must be aligned to a 2K
Chris Kay4b7660a2022-09-29 14:36:53 +0100107 * address but we need to place them in a separate page so that we can set
108 * individual permissions on them, so the actual alignment needed is the
109 * page size.
Antonio Nino Diazc41f2062017-10-24 10:07:35 +0100110 *
111 * There's no need to include this into the RO section of BL31 because it
112 * doesn't need to be accessed by BL31.
113 */
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000114 spm_shim_exceptions : ALIGN(PAGE_SIZE) {
Antonio Nino Diazc41f2062017-10-24 10:07:35 +0100115 __SPM_SHIM_EXCEPTIONS_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100116
Antonio Nino Diazc41f2062017-10-24 10:07:35 +0100117 *(.spm_shim_exceptions)
Chris Kay4b7660a2022-09-29 14:36:53 +0100118
Roberto Vargasd93fde32018-04-11 11:53:31 +0100119 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100120
Antonio Nino Diazc41f2062017-10-24 10:07:35 +0100121 __SPM_SHIM_EXCEPTIONS_END__ = .;
Ard Biesheuvel447d56f2019-01-06 10:07:24 +0100122 } >SPM_SHIM_EXCEPTIONS_VMA AT>RAM
123
124 PROVIDE(__SPM_SHIM_EXCEPTIONS_LMA__ = LOADADDR(spm_shim_exceptions));
Chris Kay4b7660a2022-09-29 14:36:53 +0100125
Ard Biesheuvel447d56f2019-01-06 10:07:24 +0100126 . = LOADADDR(spm_shim_exceptions) + SIZEOF(spm_shim_exceptions);
Chris Kay4b7660a2022-09-29 14:36:53 +0100127#endif /* SPM_MM */
Antonio Nino Diazc41f2062017-10-24 10:07:35 +0100128
Chris Kay4b7660a2022-09-29 14:36:53 +0100129 __RW_START__ = .;
Achin Guptae9c4a642015-09-11 16:03:13 +0100130
Masahiro Yamadac5864d82020-04-22 10:50:12 +0900131 DATA_SECTION >RAM
Masahiro Yamada85fa00e2020-04-22 11:27:55 +0900132 RELA_SECTION >RAM
Soby Mathew4e28c202018-10-14 08:09:22 +0100133
Sandrine Bailleuxe2e0c652014-06-16 16:12:27 +0100134#ifdef BL31_PROGBITS_LIMIT
Juan Castillo7d199412015-12-14 09:35:25 +0000135 ASSERT(. <= BL31_PROGBITS_LIMIT, "BL31 progbits has exceeded its limit.")
Chris Kay4b7660a2022-09-29 14:36:53 +0100136#endif /* BL31_PROGBITS_LIMIT */
Sandrine Bailleuxe2e0c652014-06-16 16:12:27 +0100137
Samuel Holland31a14e12018-10-17 21:40:18 -0500138#if SEPARATE_NOBITS_REGION
Madhukar Pappireddyf4e6ea62020-01-27 15:32:15 -0600139 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100140
Samuel Holland31a14e12018-10-17 21:40:18 -0500141 __RW_END__ = .;
142 __BL31_END__ = .;
143
144 ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.")
145
146 . = BL31_NOBITS_BASE;
Chris Kay4b7660a2022-09-29 14:36:53 +0100147
Samuel Holland31a14e12018-10-17 21:40:18 -0500148 ASSERT(. == ALIGN(PAGE_SIZE),
Chris Kay4b7660a2022-09-29 14:36:53 +0100149 "BL31 NOBITS base address is not aligned on a page boundary.")
Samuel Holland31a14e12018-10-17 21:40:18 -0500150
151 __NOBITS_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100152#endif /* SEPARATE_NOBITS_REGION */
Samuel Holland31a14e12018-10-17 21:40:18 -0500153
Masahiro Yamada403990e2020-04-07 13:04:24 +0900154 STACK_SECTION >NOBITS
Masahiro Yamadadd053b62020-03-26 13:16:33 +0900155 BSS_SECTION >NOBITS
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900156 XLAT_TABLE_SECTION >NOBITS
Achin Guptaa0cd9892014-02-09 13:30:38 +0000157
Soby Mathew2ae20432015-01-08 18:02:44 +0000158#if USE_COHERENT_MEM
Achin Guptaa0cd9892014-02-09 13:30:38 +0000159 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100160 * The base address of the coherent memory section must be page-aligned to
161 * guarantee that the coherent data are stored on their own pages and are
162 * not mixed with normal data. This is required to set up the correct
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000163 * memory attributes for the coherent data page tables.
164 */
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000165 coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000166 __COHERENT_RAM_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100167
Andrew Thoelkee466c9f2015-09-10 11:39:36 +0100168 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100169 * Bakery locks are stored in coherent memory. Each lock's data is
170 * contiguous and fully allocated by the compiler.
Andrew Thoelkee466c9f2015-09-10 11:39:36 +0100171 */
172 *(bakery_lock)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000173 *(tzfw_coherent_mem)
Chris Kay4b7660a2022-09-29 14:36:53 +0100174
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000175 __COHERENT_RAM_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100176
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000177 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100178 * Memory page(s) mapped to this section will be marked as device
179 * memory. No other unexpected data must creep in. Ensure the rest of
180 * the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000181 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100182 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100183
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000184 __COHERENT_RAM_END__ = .;
Samuel Holland31a14e12018-10-17 21:40:18 -0500185 } >NOBITS
Chris Kay4b7660a2022-09-29 14:36:53 +0100186#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100187
Samuel Holland31a14e12018-10-17 21:40:18 -0500188#if SEPARATE_NOBITS_REGION
Samuel Holland31a14e12018-10-17 21:40:18 -0500189 __NOBITS_END__ = .;
190
191 ASSERT(. <= BL31_NOBITS_LIMIT, "BL31 NOBITS region has exceeded its limit.")
Chris Kay4b7660a2022-09-29 14:36:53 +0100192#else /* SEPARATE_NOBITS_REGION */
Achin Guptae9c4a642015-09-11 16:03:13 +0100193 __RW_END__ = .;
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000194 __BL31_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100195
Samuel Holland322df2a2022-04-08 22:22:04 -0500196 ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.")
Chris Kay4b7660a2022-09-29 14:36:53 +0100197#endif /* SEPARATE_NOBITS_REGION */
Samuel Holland322df2a2022-04-08 22:22:04 -0500198
Masahiro Yamadad3e7baa2020-01-17 13:44:50 +0900199 /DISCARD/ : {
200 *(.dynsym .dynstr .hash .gnu.hash)
201 }
Achin Gupta4f6ad662013-10-25 09:08:21 +0100202}