blob: d08b046e9cd1454f316be2a6927c9226e4678253 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Louis Mayencourt944ade82019-08-08 12:03:26 +01002 * 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
Dan Handleyed6ff952014-05-14 17:44:19 +01007#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Masahiro Yamada0b67e562020-03-09 17:39:48 +09009#include <common/bl_common.ld.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010#include <lib/xlat_tables/xlat_tables_defs.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010011
12OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
13OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
Jeenu Viswambharan2a30a752014-03-11 11:06:45 +000014ENTRY(bl2_entrypoint)
Achin Gupta4f6ad662013-10-25 09:08:21 +010015
16MEMORY {
Juan Castillofd8c0772014-09-16 10:40:35 +010017 RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE
Achin Gupta4f6ad662013-10-25 09:08:21 +010018}
19
20
21SECTIONS
22{
23 . = BL2_BASE;
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000024 ASSERT(. == ALIGN(PAGE_SIZE),
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000025 "BL2_BASE address is not aligned on a page boundary.")
Achin Gupta4f6ad662013-10-25 09:08:21 +010026
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010027#if SEPARATE_CODE_AND_RODATA
28 .text . : {
29 __TEXT_START__ = .;
30 *bl2_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050031 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010032 *(.vectors)
Roberto Vargasd93fde32018-04-11 11:53:31 +010033 . = ALIGN(PAGE_SIZE);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010034 __TEXT_END__ = .;
35 } >RAM
36
Roberto Vargas1d04c632018-05-10 11:01:16 +010037 /* .ARM.extab and .ARM.exidx are only added because Clang need them */
38 .ARM.extab . : {
39 *(.ARM.extab* .gnu.linkonce.armextab.*)
40 } >RAM
41
42 .ARM.exidx . : {
43 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
44 } >RAM
45
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010046 .rodata . : {
47 __RODATA_START__ = .;
Samuel Holland23f5e542019-10-20 16:11:25 -050048 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010049
Louis Mayencourt944ade82019-08-08 12:03:26 +010050 . = ALIGN(8);
51 __FCONF_POPULATOR_START__ = .;
52 KEEP(*(.fconf_populator))
53 __FCONF_POPULATOR_END__ = .;
54
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010055 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
56 . = ALIGN(8);
57 __PARSER_LIB_DESCS_START__ = .;
58 KEEP(*(.img_parser_lib_descs))
59 __PARSER_LIB_DESCS_END__ = .;
60
Roberto Vargasd93fde32018-04-11 11:53:31 +010061 . = ALIGN(PAGE_SIZE);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010062 __RODATA_END__ = .;
63 } >RAM
64#else
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000065 ro . : {
66 __RO_START__ = .;
Andrew Thoelkee01ea342014-03-18 07:13:52 +000067 *bl2_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050068 *(SORT_BY_ALIGNMENT(.text*))
69 *(SORT_BY_ALIGNMENT(.rodata*))
Juan Castillo8e55d932015-04-02 09:48:16 +010070
Louis Mayencourt944ade82019-08-08 12:03:26 +010071 . = ALIGN(8);
72 __FCONF_POPULATOR_START__ = .;
73 KEEP(*(.fconf_populator))
74 __FCONF_POPULATOR_END__ = .;
75
Juan Castillo8e55d932015-04-02 09:48:16 +010076 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
77 . = ALIGN(8);
78 __PARSER_LIB_DESCS_START__ = .;
79 KEEP(*(.img_parser_lib_descs))
80 __PARSER_LIB_DESCS_END__ = .;
81
Achin Guptab739f222014-01-18 16:50:09 +000082 *(.vectors)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000083 __RO_END_UNALIGNED__ = .;
84 /*
85 * Memory page(s) mapped to this section will be marked as
86 * read-only, executable. No RW data from the next section must
87 * creep in. Ensure the rest of the current memory page is unused.
88 */
Roberto Vargasd93fde32018-04-11 11:53:31 +010089 . = ALIGN(PAGE_SIZE);
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000090 __RO_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +010091 } >RAM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010092#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +010093
Achin Guptae9c4a642015-09-11 16:03:13 +010094 /*
95 * Define a linker symbol to mark start of the RW memory area for this
96 * image.
97 */
98 __RW_START__ = . ;
99
Douglas Raillard306593d2017-02-24 18:14:15 +0000100 /*
101 * .data must be placed at a lower address than the stacks if the stack
102 * protector is enabled. Alternatively, the .data.stack_protector_canary
103 * section can be placed independently of the main .data section.
104 */
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000105 .data . : {
106 __DATA_START__ = .;
Samuel Holland23f5e542019-10-20 16:11:25 -0500107 *(SORT_BY_ALIGNMENT(.data*))
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000108 __DATA_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100109 } >RAM
110
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000111 stacks (NOLOAD) : {
112 __STACKS_START__ = .;
113 *(tzfw_normal_stacks)
114 __STACKS_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100115 } >RAM
116
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000117 /*
118 * The .bss section gets initialised to 0 at runtime.
Douglas Raillard21362a92016-12-02 13:51:54 +0000119 * Its base address should be 16-byte aligned for better performance of the
120 * zero-initialization code.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000121 */
122 .bss : ALIGN(16) {
123 __BSS_START__ = .;
Andrew Thoelkee01ea342014-03-18 07:13:52 +0000124 *(SORT_BY_ALIGNMENT(.bss*))
Achin Gupta4f6ad662013-10-25 09:08:21 +0100125 *(COMMON)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000126 __BSS_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100127 } >RAM
128
Masahiro Yamada0b67e562020-03-09 17:39:48 +0900129 XLAT_TABLE_SECTION >RAM
Achin Guptaa0cd9892014-02-09 13:30:38 +0000130
Soby Mathew2ae20432015-01-08 18:02:44 +0000131#if USE_COHERENT_MEM
Achin Guptaa0cd9892014-02-09 13:30:38 +0000132 /*
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000133 * The base address of the coherent memory section must be page-aligned (4K)
134 * to guarantee that the coherent data are stored on their own pages and
135 * are not mixed with normal data. This is required to set up the correct
136 * memory attributes for the coherent data page tables.
137 */
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000138 coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000139 __COHERENT_RAM_START__ = .;
140 *(tzfw_coherent_mem)
141 __COHERENT_RAM_END_UNALIGNED__ = .;
142 /*
143 * Memory page(s) mapped to this section will be marked
144 * as device memory. No other unexpected data must creep in.
145 * Ensure the rest of the current memory page is unused.
146 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100147 . = ALIGN(PAGE_SIZE);
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000148 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100149 } >RAM
Soby Mathew2ae20432015-01-08 18:02:44 +0000150#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100151
Achin Guptae9c4a642015-09-11 16:03:13 +0100152 /*
153 * Define a linker symbol to mark end of the RW memory area for this
154 * image.
155 */
156 __RW_END__ = .;
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000157 __BL2_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100158
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000159 __BSS_SIZE__ = SIZEOF(.bss);
Soby Mathew2ae20432015-01-08 18:02:44 +0000160
161#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000162 __COHERENT_RAM_UNALIGNED_SIZE__ =
163 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Soby Mathew2ae20432015-01-08 18:02:44 +0000164#endif
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100165
166 ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100167}