blob: 5f689d55c00f554761ceb129bf7c544d41da6bd8 [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 . : {
28 __TEXT_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010029
Zelalem Aweke688fbf72021-07-09 11:37:10 -050030#if ENABLE_RME
31 *bl2_rme_entrypoint.o(.text*)
32#else /* ENABLE_RME */
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010033 *bl2_entrypoint.o(.text*)
Zelalem Aweke688fbf72021-07-09 11:37:10 -050034#endif /* ENABLE_RME */
Chris Kay4b7660a2022-09-29 14:36:53 +010035
Samuel Holland23f5e542019-10-20 16:11:25 -050036 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010037 *(.vectors)
Chris Kay4b7660a2022-09-29 14:36:53 +010038
Roberto Vargasd93fde32018-04-11 11:53:31 +010039 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010040
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010041 __TEXT_END__ = .;
Jorge Troncosoda284d52022-10-20 21:42:06 -070042 } >RAM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010043
Chris Kay4b7660a2022-09-29 14:36:53 +010044 /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
Jorge Troncosoda284d52022-10-20 21:42:06 -070045 .ARM.extab . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010046 *(.ARM.extab* .gnu.linkonce.armextab.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070047 } >RAM
Roberto Vargas1d04c632018-05-10 11:01:16 +010048
Jorge Troncosoda284d52022-10-20 21:42:06 -070049 .ARM.exidx . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010050 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070051 } >RAM
Roberto Vargas1d04c632018-05-10 11:01:16 +010052
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010053 .rodata . : {
54 __RODATA_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010055
Samuel Holland23f5e542019-10-20 16:11:25 -050056 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010057
Chris Kay4b7660a2022-09-29 14:36:53 +010058 RODATA_COMMON
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010059
Roberto Vargasd93fde32018-04-11 11:53:31 +010060 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010061
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010062 __RODATA_END__ = .;
63 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +010064#else /* SEPARATE_CODE_AND_RODATA */
Chris Kay33bfc5e2023-02-14 11:30:04 +000065 .ro . : {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000066 __RO_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010067
Andrew Thoelkee01ea342014-03-18 07:13:52 +000068 *bl2_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050069 *(SORT_BY_ALIGNMENT(.text*))
70 *(SORT_BY_ALIGNMENT(.rodata*))
Juan Castillo8e55d932015-04-02 09:48:16 +010071
Chris Kay4b7660a2022-09-29 14:36:53 +010072 RODATA_COMMON
Juan Castillo8e55d932015-04-02 09:48:16 +010073
Achin Guptab739f222014-01-18 16:50:09 +000074 *(.vectors)
Chris Kay4b7660a2022-09-29 14:36:53 +010075
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000076 __RO_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010077
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000078 /*
Chris Kay4b7660a2022-09-29 14:36:53 +010079 * Memory page(s) mapped to this section will be marked as read-only,
80 * executable. No RW data from the next section must creep in. Ensure
81 * that the rest of the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000082 */
Roberto Vargasd93fde32018-04-11 11:53:31 +010083 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010084
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000085 __RO_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +010086 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +010087#endif /* SEPARATE_CODE_AND_RODATA */
Achin Gupta4f6ad662013-10-25 09:08:21 +010088
Chris Kay4b7660a2022-09-29 14:36:53 +010089 __RW_START__ = .;
Achin Guptae9c4a642015-09-11 16:03:13 +010090
Masahiro Yamadac5864d82020-04-22 10:50:12 +090091 DATA_SECTION >RAM
Masahiro Yamada403990e2020-04-07 13:04:24 +090092 STACK_SECTION >RAM
Masahiro Yamadadd053b62020-03-26 13:16:33 +090093 BSS_SECTION >RAM
Masahiro Yamada0b67e562020-03-09 17:39:48 +090094 XLAT_TABLE_SECTION >RAM
Achin Guptaa0cd9892014-02-09 13:30:38 +000095
Soby Mathew2ae20432015-01-08 18:02:44 +000096#if USE_COHERENT_MEM
Achin Guptaa0cd9892014-02-09 13:30:38 +000097 /*
Chris Kay4b7660a2022-09-29 14:36:53 +010098 * The base address of the coherent memory section must be page-aligned to
99 * guarantee that the coherent data are stored on their own pages and are
100 * not mixed with normal data. This is required to set up the correct
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000101 * memory attributes for the coherent data page tables.
102 */
Chris Kay33bfc5e2023-02-14 11:30:04 +0000103 .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000104 __COHERENT_RAM_START__ = .;
Chris Kay33bfc5e2023-02-14 11:30:04 +0000105 *(.tzfw_coherent_mem)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000106 __COHERENT_RAM_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100107
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000108 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100109 * Memory page(s) mapped to this section will be marked as device
110 * memory. No other unexpected data must creep in. Ensure the rest of
111 * the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000112 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100113 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100114
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000115 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100116 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +0100117#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100118
Achin Guptae9c4a642015-09-11 16:03:13 +0100119 __RW_END__ = .;
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000120 __BL2_END__ = .;
Harrison Mutaib6f9a2b2023-04-19 10:08:56 +0100121 RAM_REGION_END = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100122
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000123 __BSS_SIZE__ = SIZEOF(.bss);
Soby Mathew2ae20432015-01-08 18:02:44 +0000124
125#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000126 __COHERENT_RAM_UNALIGNED_SIZE__ =
127 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Chris Kay4b7660a2022-09-29 14:36:53 +0100128#endif /* USE_COHERENT_MEM */
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100129
130 ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100131}