blob: 75355ebff1651c26f76d16a04b5e3cd2a5c1af4a [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Masahiro Yamada0b67e562020-03-09 17:39:48 +09002 * 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(bl1_entrypoint)
Achin Gupta4f6ad662013-10-25 09:08:21 +010013
14MEMORY {
Juan Castillofd8c0772014-09-16 10:40:35 +010015 ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
16 RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
Achin Gupta4f6ad662013-10-25 09:08:21 +010017}
18
19SECTIONS
20{
Sandrine Bailleuxf7488062014-05-22 15:21:35 +010021 . = BL1_RO_BASE;
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000022 ASSERT(. == ALIGN(PAGE_SIZE),
Sandrine Bailleuxf7488062014-05-22 15:21:35 +010023 "BL1_RO_BASE address is not aligned on a page boundary.")
24
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010025#if SEPARATE_CODE_AND_RODATA
26 .text . : {
27 __TEXT_START__ = .;
28 *bl1_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050029 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010030 *(.vectors)
Roberto Vargasd93fde32018-04-11 11:53:31 +010031 . = ALIGN(PAGE_SIZE);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010032 __TEXT_END__ = .;
33 } >ROM
34
Roberto Vargas1d04c632018-05-10 11:01:16 +010035 /* .ARM.extab and .ARM.exidx are only added because Clang need them */
36 .ARM.extab . : {
37 *(.ARM.extab* .gnu.linkonce.armextab.*)
38 } >ROM
39
40 .ARM.exidx . : {
41 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
42 } >ROM
43
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010044 .rodata . : {
45 __RODATA_START__ = .;
Samuel Holland23f5e542019-10-20 16:11:25 -050046 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010047
Masahiro Yamada583f8dd2020-03-26 10:57:12 +090048 RODATA_COMMON
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010049
50 /*
51 * No need to pad out the .rodata section to a page boundary. Next is
52 * the .data section, which can mapped in ROM with the same memory
53 * attributes as the .rodata section.
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080054 *
55 * Pad out to 16 bytes though as .data section needs to be 16 byte
56 * aligned and lld does not align the LMA to the aligment specified
57 * on the .data section.
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010058 */
59 __RODATA_END__ = .;
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080060 . = ALIGN(16);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010061 } >ROM
62#else
Sandrine Bailleuxf7488062014-05-22 15:21:35 +010063 ro . : {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000064 __RO_START__ = .;
Andrew Thoelkee01ea342014-03-18 07:13:52 +000065 *bl1_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050066 *(SORT_BY_ALIGNMENT(.text*))
67 *(SORT_BY_ALIGNMENT(.rodata*))
Soby Mathewc704cbc2014-08-14 11:33:56 +010068
Masahiro Yamada583f8dd2020-03-26 10:57:12 +090069 RODATA_COMMON
Soby Mathewc704cbc2014-08-14 11:33:56 +010070
Achin Guptab739f222014-01-18 16:50:09 +000071 *(.vectors)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000072 __RO_END__ = .;
Arve Hjønnevåg1488cbe2020-02-07 14:12:35 -080073
74 /*
75 * Pad out to 16 bytes as .data section needs to be 16 byte aligned and
76 * lld does not align the LMA to the aligment specified on the .data
77 * section.
78 */
79 . = ALIGN(16);
Achin Gupta4f6ad662013-10-25 09:08:21 +010080 } >ROM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010081#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +010082
Soby Mathewc704cbc2014-08-14 11:33:56 +010083 ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
84 "cpu_ops not defined for this platform.")
85
Douglas Raillard306593d2017-02-24 18:14:15 +000086 . = BL1_RW_BASE;
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000087 ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
Douglas Raillard306593d2017-02-24 18:14:15 +000088 "BL1_RW_BASE address is not aligned on a page boundary.")
89
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000090 /*
91 * The .data section gets copied from ROM to RAM at runtime.
Douglas Raillard306593d2017-02-24 18:14:15 +000092 * Its LMA should be 16-byte aligned to allow efficient copying of 16-bytes
93 * aligned regions in it.
Sandrine Bailleuxf7488062014-05-22 15:21:35 +010094 * Its VMA must be page-aligned as it marks the first read/write page.
Douglas Raillard306593d2017-02-24 18:14:15 +000095 *
96 * It must be placed at a lower address than the stacks if the stack
97 * protector is enabled. Alternatively, the .data.stack_protector_canary
98 * section can be placed independently of the main .data section.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000099 */
Sandrine Bailleuxf7488062014-05-22 15:21:35 +0100100 .data . : ALIGN(16) {
Achin Gupta4f6ad662013-10-25 09:08:21 +0100101 __DATA_RAM_START__ = .;
Samuel Holland23f5e542019-10-20 16:11:25 -0500102 *(SORT_BY_ALIGNMENT(.data*))
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000103 __DATA_RAM_END__ = .;
104 } >RAM AT>ROM
Achin Gupta4f6ad662013-10-25 09:08:21 +0100105
Sandrine Bailleuxf7488062014-05-22 15:21:35 +0100106 stacks . (NOLOAD) : {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000107 __STACKS_START__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100108 *(tzfw_normal_stacks)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000109 __STACKS_END__ = .;
110 } >RAM
111
Masahiro Yamadadd053b62020-03-26 13:16:33 +0900112 BSS_SECTION >RAM
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900113 XLAT_TABLE_SECTION >RAM
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000114
Soby Mathew2ae20432015-01-08 18:02:44 +0000115#if USE_COHERENT_MEM
Jeenu Viswambharan74cbb832014-02-17 17:26:51 +0000116 /*
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000117 * The base address of the coherent memory section must be page-aligned (4K)
118 * to guarantee that the coherent data are stored on their own pages and
119 * are not mixed with normal data. This is required to set up the correct
120 * memory attributes for the coherent data page tables.
121 */
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000122 coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000123 __COHERENT_RAM_START__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100124 *(tzfw_coherent_mem)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000125 __COHERENT_RAM_END_UNALIGNED__ = .;
126 /*
127 * Memory page(s) mapped to this section will be marked
128 * as device memory. No other unexpected data must creep in.
129 * Ensure the rest of the current memory page is unused.
130 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100131 . = ALIGN(PAGE_SIZE);
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000132 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100133 } >RAM
Soby Mathew2ae20432015-01-08 18:02:44 +0000134#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100135
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000136 __BL1_RAM_START__ = ADDR(.data);
137 __BL1_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100138
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000139 __DATA_ROM_START__ = LOADADDR(.data);
140 __DATA_SIZE__ = SIZEOF(.data);
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100141
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100142 /*
143 * The .data section is the last PROGBITS section so its end marks the end
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100144 * of BL1's actual content in Trusted ROM.
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100145 */
Sandrine Bailleux6c2daed2016-06-15 13:53:50 +0100146 __BL1_ROM_END__ = __DATA_ROM_START__ + __DATA_SIZE__;
147 ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
148 "BL1's ROM content has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100149
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000150 __BSS_SIZE__ = SIZEOF(.bss);
151
Soby Mathew2ae20432015-01-08 18:02:44 +0000152#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000153 __COHERENT_RAM_UNALIGNED_SIZE__ =
154 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Soby Mathew2ae20432015-01-08 18:02:44 +0000155#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100156
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100157 ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100158}