blob: a2527e63a9a78a59444d4659b606bc9a3666020c [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)
Chris Kay4b7660a2022-09-29 14:36:53 +010044
Roberto Vargasd93fde32018-04-11 11:53:31 +010045 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +010046
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010047 __TEXT_END__ = .;
Jorge Troncosoda284d52022-10-20 21:42:06 -070048 } >ROM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010049
Chris Kay4b7660a2022-09-29 14:36:53 +010050 /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
Jorge Troncosoda284d52022-10-20 21:42:06 -070051 .ARM.extab . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010052 *(.ARM.extab* .gnu.linkonce.armextab.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070053 } >ROM
Roberto Vargas1d04c632018-05-10 11:01:16 +010054
Jorge Troncosoda284d52022-10-20 21:42:06 -070055 .ARM.exidx . : {
Roberto Vargas1d04c632018-05-10 11:01:16 +010056 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Jorge Troncosoda284d52022-10-20 21:42:06 -070057 } >ROM
Roberto Vargas1d04c632018-05-10 11:01:16 +010058
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010059 .rodata . : {
60 __RODATA_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010061
Samuel Holland23f5e542019-10-20 16:11:25 -050062 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010063
Chris Kay4b7660a2022-09-29 14:36:53 +010064 RODATA_COMMON
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010065
66 /*
67 * No need to pad out the .rodata section to a page boundary. Next is
68 * the .data section, which can mapped in ROM with the same memory
69 * attributes as the .rodata section.
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080070 *
Chris Kay4b7660a2022-09-29 14:36:53 +010071 * Pad out to 16 bytes though as .data section needs to be 16-byte
72 * aligned and lld does not align the LMA to the alignment specified
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080073 * on the .data section.
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010074 */
75 __RODATA_END__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010076
77 . = ALIGN(16);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010078 } >ROM
Chris Kay4b7660a2022-09-29 14:36:53 +010079#else /* SEPARATE_CODE_AND_RODATA */
Chris Kay33bfc5e2023-02-14 11:30:04 +000080 .ro . : {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000081 __RO_START__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +010082
Andrew Thoelkee01ea342014-03-18 07:13:52 +000083 *bl1_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050084 *(SORT_BY_ALIGNMENT(.text*))
85 *(SORT_BY_ALIGNMENT(.rodata*))
Soby Mathewc704cbc2014-08-14 11:33:56 +010086
Chris Kay4b7660a2022-09-29 14:36:53 +010087 RODATA_COMMON
Soby Mathewc704cbc2014-08-14 11:33:56 +010088
Achin Guptab739f222014-01-18 16:50:09 +000089 *(.vectors)
Chris Kay4b7660a2022-09-29 14:36:53 +010090
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000091 __RO_END__ = .;
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080092
93 /*
Chris Kay4b7660a2022-09-29 14:36:53 +010094 * Pad out to 16 bytes as the .data section needs to be 16-byte aligned
95 * and lld does not align the LMA to the alignment specified on the
96 * .data section.
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080097 */
Chris Kay4b7660a2022-09-29 14:36:53 +010098 . = ALIGN(16);
Achin Gupta4f6ad662013-10-25 09:08:21 +010099 } >ROM
Chris Kay4b7660a2022-09-29 14:36:53 +0100100#endif /* SEPARATE_CODE_AND_RODATA */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100101
Soby Mathewc704cbc2014-08-14 11:33:56 +0100102 ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
Chris Kay4b7660a2022-09-29 14:36:53 +0100103 "cpu_ops not defined for this platform.")
Soby Mathewc704cbc2014-08-14 11:33:56 +0100104
Harrison Mutaie420d1a2023-04-19 09:30:15 +0100105 ROM_REGION_END = .;
Douglas Raillard306593d2017-02-24 18:14:15 +0000106 . = BL1_RW_BASE;
Chris Kay4b7660a2022-09-29 14:36:53 +0100107
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000108 ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
Chris Kay4b7660a2022-09-29 14:36:53 +0100109 "BL1_RW_BASE address is not aligned on a page boundary.")
Douglas Raillard306593d2017-02-24 18:14:15 +0000110
Masahiro Yamadac5864d82020-04-22 10:50:12 +0900111 DATA_SECTION >RAM AT>ROM
Chris Kay4b7660a2022-09-29 14:36:53 +0100112
Masahiro Yamadac5864d82020-04-22 10:50:12 +0900113 __DATA_RAM_START__ = __DATA_START__;
114 __DATA_RAM_END__ = __DATA_END__;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100115
Masahiro Yamada403990e2020-04-07 13:04:24 +0900116 STACK_SECTION >RAM
Masahiro Yamadadd053b62020-03-26 13:16:33 +0900117 BSS_SECTION >RAM
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900118 XLAT_TABLE_SECTION >RAM
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000119
Soby Mathew2ae20432015-01-08 18:02:44 +0000120#if USE_COHERENT_MEM
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000121 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100122 * The base address of the coherent memory section must be page-aligned to
123 * guarantee that the coherent data are stored on their own pages and are
124 * not mixed with normal data. This is required to set up the correct memory
125 * attributes for the coherent data page tables.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000126 */
Chris Kay33bfc5e2023-02-14 11:30:04 +0000127 .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000128 __COHERENT_RAM_START__ = .;
Chris Kay33bfc5e2023-02-14 11:30:04 +0000129 *(.tzfw_coherent_mem)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000130 __COHERENT_RAM_END_UNALIGNED__ = .;
Chris Kay4b7660a2022-09-29 14:36:53 +0100131
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000132 /*
Chris Kay4b7660a2022-09-29 14:36:53 +0100133 * Memory page(s) mapped to this section will be marked as device
134 * memory. No other unexpected data must creep in. Ensure the rest of
135 * the current memory page is unused.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000136 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100137 . = ALIGN(PAGE_SIZE);
Chris Kay4b7660a2022-09-29 14:36:53 +0100138
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000139 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100140 } >RAM
Chris Kay4b7660a2022-09-29 14:36:53 +0100141#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100142
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000143 __BL1_RAM_START__ = ADDR(.data);
144 __BL1_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100145
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000146 __DATA_ROM_START__ = LOADADDR(.data);
147 __DATA_SIZE__ = SIZEOF(.data);
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100148
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100149 /*
150 * The .data section is the last PROGBITS section so its end marks the end
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100151 * of BL1's actual content in Trusted ROM.
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100152 */
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100153 __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__;
Chris Kay4b7660a2022-09-29 14:36:53 +0100154
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100155 ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
Chris Kay4b7660a2022-09-29 14:36:53 +0100156 "BL1's ROM content has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100157
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000158 __BSS_SIZE__ = SIZEOF(.bss);
159
Soby Mathew2ae20432015-01-08 18:02:44 +0000160#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000161 __COHERENT_RAM_UNALIGNED_SIZE__ =
162 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Chris Kay4b7660a2022-09-29 14:36:53 +0100163#endif /* USE_COHERENT_MEM */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100164
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100165 ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
Harrison Mutaie420d1a2023-04-19 09:30:15 +0100166 RAM_REGION_END = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100167}