blob: 310e6fe789c449bb41c460b9518169f01bb47dc4 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Chris Kay33bfc5e2023-02-14 11:30:04 +00002 * Copyright (c) 2013-2023, 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(bl2_entrypoint)
Achin Gupta4f6ad662013-10-25 09:08:21 +010013
14MEMORY {
Juan Castillofd8c0772014-09-16 10:40:35 +010015 RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE
Achin Gupta4f6ad662013-10-25 09:08:21 +010016}
17
Chris Kay4b7660a2022-09-29 14:36:53 +010018SECTIONS {
Harrison Mutaib6f9a2b2023-04-19 10:08:56 +010019 RAM_REGION_START = ORIGIN(RAM);
20 RAM_REGION_LENGTH = LENGTH(RAM);
Achin Gupta4f6ad662013-10-25 09:08:21 +010021 . = BL2_BASE;
Chris Kay4b7660a2022-09-29 14:36:53 +010022
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000023 ASSERT(. == ALIGN(PAGE_SIZE),
Chris Kay4b7660a2022-09-29 14:36:53 +010024 "BL2_BASE address is not aligned on a page boundary.")
Achin Gupta4f6ad662013-10-25 09:08:21 +010025
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010026#if SEPARATE_CODE_AND_RODATA
27 .text . : {
Andrey Skvortsov08526ad2023-09-05 22:09:25 +030028 ASSERT(. == ALIGN(PAGE_SIZE),
29 ".text address is not aligned on a page boundary.");
30
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010031 __TEXT_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010032
Zelalem Aweke688fbf72021-07-09 11:37:10 -050033#if ENABLE_RME
34 *bl2_rme_entrypoint.o(.text*)
35#else /* ENABLE_RME */
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010036 *bl2_entrypoint.o(.text*)
Zelalem Aweke688fbf72021-07-09 11:37:10 -050037#endif /* ENABLE_RME */
Chris Kay4b7660a2022-09-29 14:36:53 +010038
Samuel Holland23f5e542019-10-20 16:11:25 -050039 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010040 *(.vectors)
Michal Simek80c530e2023-04-27 14:26:03 +020041 __TEXT_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010042
Roberto Vargasd93fde32018-04-11 11:53:31 +010043 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010044
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010045 __TEXT_END__ = .;
Jorge Troncosoda284d52022-10-20 21:42:06 -070046 } >RAM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010047
Chris Kay4b7660a2022-09-29 14:36:53 +010048 /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
Jorge Troncosoda284d52022-10-20 21:42:06 -070049 .ARM.extab . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010050 *(.ARM.extab* .gnu.linkonce.armextab.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070051 } >RAM
Roberto Vargas1d04c632018-05-10 11:01:16 +010052
Jorge Troncosoda284d52022-10-20 21:42:06 -070053 .ARM.exidx . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010054 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070055 } >RAM
Roberto Vargas1d04c632018-05-10 11:01:16 +010056
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010057 .rodata . : {
58 __RODATA_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010059
Samuel Holland23f5e542019-10-20 16:11:25 -050060 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010061
Chris Kay4b7660a2022-09-29 14:36:53 +010062 RODATA_COMMON
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010063
Michal Simek80c530e2023-04-27 14:26:03 +020064 __RODATA_END_UNALIGNED__ = .;
Roberto Vargasd93fde32018-04-11 11:53:31 +010065 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010066
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010067 __RODATA_END__ = .;
68 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +010069#else /* SEPARATE_CODE_AND_RODATA */
Chris Kay33bfc5e2023-02-14 11:30:04 +000070 .ro . : {
Andrey Skvortsov08526ad2023-09-05 22:09:25 +030071 ASSERT(. == ALIGN(PAGE_SIZE),
72 ".ro address is not aligned on a page boundary.");
73
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000074 __RO_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010075
Andrew Thoelkee01ea342014-03-18 07:13:52 +000076 *bl2_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050077 *(SORT_BY_ALIGNMENT(.text*))
78 *(SORT_BY_ALIGNMENT(.rodata*))
Juan Castillo8e55d932015-04-02 09:48:16 +010079
Chris Kay4b7660a2022-09-29 14:36:53 +010080 RODATA_COMMON
Juan Castillo8e55d932015-04-02 09:48:16 +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 /*
Chris Kay4b7660a2022-09-29 14:36:53 +010087 * Memory page(s) mapped to this section will be marked as read-only,
88 * 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
Chris Kay4b7660a2022-09-29 14:36:53 +010097 __RW_START__ = .;
Achin Guptae9c4a642015-09-11 16:03:13 +010098
Masahiro Yamadac5864d82020-04-22 10:50:12 +090099 DATA_SECTION >RAM
Masahiro Yamada403990e2020-04-07 13:04:24 +0900100 STACK_SECTION >RAM
Masahiro Yamadadd053b62020-03-26 13:16:33 +0900101 BSS_SECTION >RAM
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900102 XLAT_TABLE_SECTION >RAM
Achin Guptaa0cd9892014-02-09 13:30:38 +0000103
Soby Mathew2ae20432015-01-08 18:02:44 +0000104#if USE_COHERENT_MEM
Achin Guptaa0cd9892014-02-09 13:30:38 +0000105 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100106 * The base address of the coherent memory section must be page-aligned to
107 * guarantee that the coherent data are stored on their own pages and are
108 * not mixed with normal data. This is required to set up the correct
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000109 * memory attributes for the coherent data page tables.
110 */
Chris Kay33bfc5e2023-02-14 11:30:04 +0000111 .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000112 __COHERENT_RAM_START__ = .;
Chris Kay33bfc5e2023-02-14 11:30:04 +0000113 *(.tzfw_coherent_mem)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000114 __COHERENT_RAM_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100115
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000116 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100117 * Memory page(s) mapped to this section will be marked as device
118 * memory. No other unexpected data must creep in. Ensure the rest of
119 * the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000120 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100121 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100122
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000123 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100124 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +0100125#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100126
Achin Guptae9c4a642015-09-11 16:03:13 +0100127 __RW_END__ = .;
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000128 __BL2_END__ = .;
Harrison Mutaib6f9a2b2023-04-19 10:08:56 +0100129 RAM_REGION_END = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100130
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000131 __BSS_SIZE__ = SIZEOF(.bss);
Soby Mathew2ae20432015-01-08 18:02:44 +0000132
133#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000134 __COHERENT_RAM_UNALIGNED_SIZE__ =
135 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Chris Kay4b7660a2022-09-29 14:36:53 +0100136#endif /* USE_COHERENT_MEM */
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100137
138 ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100139}