blob: 49dda855ec1cb68a3ddca4c210e9f23941dcf3ff [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Harrison Mutaie420d1a2023-04-19 09:30:15 +01002 * 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 Yamadac5864d82020-04-22 10:50:12 +09007/*
Chris Kay4b7660a2022-09-29 14:36:53 +01008 * The .data section gets copied from ROM to RAM at runtime. Its LMA should be
9 * 16-byte aligned to allow efficient copying of 16-bytes aligned regions in it.
Masahiro Yamadac5864d82020-04-22 10:50:12 +090010 * Its VMA must be page-aligned as it marks the first read/write page.
11 */
12#define DATA_ALIGN 16
13
Masahiro Yamada0b67e562020-03-09 17:39:48 +090014#include <common/bl_common.ld.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000015#include <lib/xlat_tables/xlat_tables_defs.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010016
17OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
18OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
Jeenu Viswambharan2a30a752014-03-11 11:06:45 +000019ENTRY(bl1_entrypoint)
Achin Gupta4f6ad662013-10-25 09:08:21 +010020
21MEMORY {
Juan Castillofd8c0772014-09-16 10:40:35 +010022 ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
23 RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
Achin Gupta4f6ad662013-10-25 09:08:21 +010024}
25
Chris Kay4b7660a2022-09-29 14:36:53 +010026SECTIONS {
Harrison Mutaie420d1a2023-04-19 09:30:15 +010027 ROM_REGION_START = ORIGIN(ROM);
28 ROM_REGION_LENGTH = LENGTH(ROM);
29 RAM_REGION_START = ORIGIN(RAM);
30 RAM_REGION_LENGTH = LENGTH(RAM);
31
Sandrine Bailleuxf7488062014-05-22 15:21:35 +010032 . = BL1_RO_BASE;
Chris Kay4b7660a2022-09-29 14:36:53 +010033
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000034 ASSERT(. == ALIGN(PAGE_SIZE),
Chris Kay4b7660a2022-09-29 14:36:53 +010035 "BL1_RO_BASE address is not aligned on a page boundary.")
Sandrine Bailleuxf7488062014-05-22 15:21:35 +010036
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010037#if SEPARATE_CODE_AND_RODATA
38 .text . : {
39 __TEXT_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010040
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010041 *bl1_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050042 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010043 *(.vectors)
Michal Simek80c530e2023-04-27 14:26:03 +020044 __TEXT_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010045
Roberto Vargasd93fde32018-04-11 11:53:31 +010046 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010047
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010048 __TEXT_END__ = .;
Jorge Troncosoda284d52022-10-20 21:42:06 -070049 } >ROM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010050
Chris Kay4b7660a2022-09-29 14:36:53 +010051 /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
Jorge Troncosoda284d52022-10-20 21:42:06 -070052 .ARM.extab . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010053 *(.ARM.extab* .gnu.linkonce.armextab.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070054 } >ROM
Roberto Vargas1d04c632018-05-10 11:01:16 +010055
Jorge Troncosoda284d52022-10-20 21:42:06 -070056 .ARM.exidx . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010057 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070058 } >ROM
Roberto Vargas1d04c632018-05-10 11:01:16 +010059
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010060 .rodata . : {
61 __RODATA_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010062
Samuel Holland23f5e542019-10-20 16:11:25 -050063 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010064
Chris Kay4b7660a2022-09-29 14:36:53 +010065 RODATA_COMMON
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010066
67 /*
68 * No need to pad out the .rodata section to a page boundary. Next is
69 * the .data section, which can mapped in ROM with the same memory
70 * attributes as the .rodata section.
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080071 *
Chris Kay4b7660a2022-09-29 14:36:53 +010072 * Pad out to 16 bytes though as .data section needs to be 16-byte
73 * aligned and lld does not align the LMA to the alignment specified
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080074 * on the .data section.
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010075 */
Michal Simek80c530e2023-04-27 14:26:03 +020076 __RODATA_END_UNALIGNED__ = .;
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010077 __RODATA_END__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010078
79 . = ALIGN(16);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010080 } >ROM
Chris Kay4b7660a2022-09-29 14:36:53 +010081#else /* SEPARATE_CODE_AND_RODATA */
Chris Kay33bfc5e2023-02-14 11:30:04 +000082 .ro . : {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000083 __RO_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010084
Andrew Thoelkee01ea342014-03-18 07:13:52 +000085 *bl1_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050086 *(SORT_BY_ALIGNMENT(.text*))
87 *(SORT_BY_ALIGNMENT(.rodata*))
Soby Mathewc704cbc2014-08-14 11:33:56 +010088
Chris Kay4b7660a2022-09-29 14:36:53 +010089 RODATA_COMMON
Soby Mathewc704cbc2014-08-14 11:33:56 +010090
Achin Guptab739f222014-01-18 16:50:09 +000091 *(.vectors)
Chris Kay4b7660a2022-09-29 14:36:53 +010092
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000093 __RO_END__ = .;
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080094
95 /*
Chris Kay4b7660a2022-09-29 14:36:53 +010096 * Pad out to 16 bytes as the .data section needs to be 16-byte aligned
97 * and lld does not align the LMA to the alignment specified on the
98 * .data section.
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080099 */
Chris Kay4b7660a2022-09-29 14:36:53 +0100100 . = ALIGN(16);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100101 } >ROM
Chris Kay4b7660a2022-09-29 14:36:53 +0100102#endif /* SEPARATE_CODE_AND_RODATA */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100103
Soby Mathewc704cbc2014-08-14 11:33:56 +0100104 ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
Chris Kay4b7660a2022-09-29 14:36:53 +0100105 "cpu_ops not defined for this platform.")
Soby Mathewc704cbc2014-08-14 11:33:56 +0100106
Harrison Mutaie420d1a2023-04-19 09:30:15 +0100107 ROM_REGION_END = .;
Douglas Raillard306593d2017-02-24 18:14:15 +0000108 . = BL1_RW_BASE;
Chris Kay4b7660a2022-09-29 14:36:53 +0100109
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000110 ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
Chris Kay4b7660a2022-09-29 14:36:53 +0100111 "BL1_RW_BASE address is not aligned on a page boundary.")
Douglas Raillard306593d2017-02-24 18:14:15 +0000112
Masahiro Yamadac5864d82020-04-22 10:50:12 +0900113 DATA_SECTION >RAM AT>ROM
Chris Kay4b7660a2022-09-29 14:36:53 +0100114
Masahiro Yamadac5864d82020-04-22 10:50:12 +0900115 __DATA_RAM_START__ = __DATA_START__;
116 __DATA_RAM_END__ = __DATA_END__;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100117
Masahiro Yamada403990e2020-04-07 13:04:24 +0900118 STACK_SECTION >RAM
Masahiro Yamadadd053b62020-03-26 13:16:33 +0900119 BSS_SECTION >RAM
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900120 XLAT_TABLE_SECTION >RAM
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000121
Soby Mathew2ae20432015-01-08 18:02:44 +0000122#if USE_COHERENT_MEM
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000123 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100124 * The base address of the coherent memory section must be page-aligned to
125 * guarantee that the coherent data are stored on their own pages and are
126 * not mixed with normal data. This is required to set up the correct memory
127 * attributes for the coherent data page tables.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000128 */
Chris Kay33bfc5e2023-02-14 11:30:04 +0000129 .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000130 __COHERENT_RAM_START__ = .;
Chris Kay33bfc5e2023-02-14 11:30:04 +0000131 *(.tzfw_coherent_mem)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000132 __COHERENT_RAM_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100133
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000134 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100135 * Memory page(s) mapped to this section will be marked as device
136 * memory. No other unexpected data must creep in. Ensure the rest of
137 * the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000138 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100139 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100140
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000141 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100142 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +0100143#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100144
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000145 __BL1_RAM_START__ = ADDR(.data);
146 __BL1_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100147
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000148 __DATA_ROM_START__ = LOADADDR(.data);
149 __DATA_SIZE__ = SIZEOF(.data);
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100150
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100151 /*
152 * The .data section is the last PROGBITS section so its end marks the end
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100153 * of BL1's actual content in Trusted ROM.
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100154 */
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100155 __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__;
Chris Kay4b7660a2022-09-29 14:36:53 +0100156
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100157 ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
Chris Kay4b7660a2022-09-29 14:36:53 +0100158 "BL1's ROM content has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100159
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000160 __BSS_SIZE__ = SIZEOF(.bss);
161
Soby Mathew2ae20432015-01-08 18:02:44 +0000162#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000163 __COHERENT_RAM_UNALIGNED_SIZE__ =
164 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Chris Kay4b7660a2022-09-29 14:36:53 +0100165#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100166
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100167 ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
Harrison Mutaie420d1a2023-04-19 09:30:15 +0100168 RAM_REGION_END = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100169}