blob: c1338e22d34302fc3b9701fbb66d40eb1b80c032 [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
9#include <lib/xlat_tables/xlat_tables_defs.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010010
11OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
12OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
Jeenu Viswambharan2a30a752014-03-11 11:06:45 +000013ENTRY(bl2_entrypoint)
Achin Gupta4f6ad662013-10-25 09:08:21 +010014
15MEMORY {
Juan Castillofd8c0772014-09-16 10:40:35 +010016 RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE
Achin Gupta4f6ad662013-10-25 09:08:21 +010017}
18
19
20SECTIONS
21{
22 . = BL2_BASE;
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000023 ASSERT(. == ALIGN(PAGE_SIZE),
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000024 "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__ = .;
29 *bl2_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050030 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010031 *(.vectors)
Roberto Vargasd93fde32018-04-11 11:53:31 +010032 . = ALIGN(PAGE_SIZE);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010033 __TEXT_END__ = .;
34 } >RAM
35
Roberto Vargas1d04c632018-05-10 11:01:16 +010036 /* .ARM.extab and .ARM.exidx are only added because Clang need them */
37 .ARM.extab . : {
38 *(.ARM.extab* .gnu.linkonce.armextab.*)
39 } >RAM
40
41 .ARM.exidx . : {
42 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
43 } >RAM
44
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010045 .rodata . : {
46 __RODATA_START__ = .;
Samuel Holland23f5e542019-10-20 16:11:25 -050047 *(SORT_BY_ALIGNMENT(.rodata*))
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010048
Louis Mayencourt944ade82019-08-08 12:03:26 +010049 . = ALIGN(8);
50 __FCONF_POPULATOR_START__ = .;
51 KEEP(*(.fconf_populator))
52 __FCONF_POPULATOR_END__ = .;
53
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010054 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
55 . = ALIGN(8);
56 __PARSER_LIB_DESCS_START__ = .;
57 KEEP(*(.img_parser_lib_descs))
58 __PARSER_LIB_DESCS_END__ = .;
59
Roberto Vargasd93fde32018-04-11 11:53:31 +010060 . = ALIGN(PAGE_SIZE);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010061 __RODATA_END__ = .;
62 } >RAM
63#else
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000064 ro . : {
65 __RO_START__ = .;
Andrew Thoelkee01ea342014-03-18 07:13:52 +000066 *bl2_entrypoint.o(.text*)
Samuel Holland23f5e542019-10-20 16:11:25 -050067 *(SORT_BY_ALIGNMENT(.text*))
68 *(SORT_BY_ALIGNMENT(.rodata*))
Juan Castillo8e55d932015-04-02 09:48:16 +010069
Louis Mayencourt944ade82019-08-08 12:03:26 +010070 . = ALIGN(8);
71 __FCONF_POPULATOR_START__ = .;
72 KEEP(*(.fconf_populator))
73 __FCONF_POPULATOR_END__ = .;
74
Juan Castillo8e55d932015-04-02 09:48:16 +010075 /* Ensure 8-byte alignment for descriptors and ensure inclusion */
76 . = ALIGN(8);
77 __PARSER_LIB_DESCS_START__ = .;
78 KEEP(*(.img_parser_lib_descs))
79 __PARSER_LIB_DESCS_END__ = .;
80
Achin Guptab739f222014-01-18 16:50:09 +000081 *(.vectors)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000082 __RO_END_UNALIGNED__ = .;
83 /*
84 * Memory page(s) mapped to this section will be marked as
85 * read-only, executable. No RW data from the next section must
86 * creep in. Ensure the rest of the current memory page is unused.
87 */
Roberto Vargasd93fde32018-04-11 11:53:31 +010088 . = ALIGN(PAGE_SIZE);
Sandrine Bailleux8d69a032013-11-27 09:38:52 +000089 __RO_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +010090 } >RAM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010091#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +010092
Achin Guptae9c4a642015-09-11 16:03:13 +010093 /*
94 * Define a linker symbol to mark start of the RW memory area for this
95 * image.
96 */
97 __RW_START__ = . ;
98
Douglas Raillard306593d2017-02-24 18:14:15 +000099 /*
100 * .data must be placed at a lower address than the stacks if the stack
101 * protector is enabled. Alternatively, the .data.stack_protector_canary
102 * section can be placed independently of the main .data section.
103 */
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000104 .data . : {
105 __DATA_START__ = .;
Samuel Holland23f5e542019-10-20 16:11:25 -0500106 *(SORT_BY_ALIGNMENT(.data*))
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000107 __DATA_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100108 } >RAM
109
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000110 stacks (NOLOAD) : {
111 __STACKS_START__ = .;
112 *(tzfw_normal_stacks)
113 __STACKS_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100114 } >RAM
115
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000116 /*
117 * The .bss section gets initialised to 0 at runtime.
Douglas Raillard21362a92016-12-02 13:51:54 +0000118 * Its base address should be 16-byte aligned for better performance of the
119 * zero-initialization code.
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000120 */
121 .bss : ALIGN(16) {
122 __BSS_START__ = .;
Andrew Thoelkee01ea342014-03-18 07:13:52 +0000123 *(SORT_BY_ALIGNMENT(.bss*))
Achin Gupta4f6ad662013-10-25 09:08:21 +0100124 *(COMMON)
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000125 __BSS_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100126 } >RAM
127
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000128 /*
Jeenu Viswambharan97cc9ee2014-02-24 15:20:28 +0000129 * The xlat_table section is for full, aligned page tables (4K).
Achin Guptaa0cd9892014-02-09 13:30:38 +0000130 * Removing them from .bss avoids forcing 4K alignment on
Antonio Nino Diaz7c2a3ca2018-02-23 15:07:54 +0000131 * the .bss section. The tables are initialized to zero by the translation
132 * tables library.
Achin Guptaa0cd9892014-02-09 13:30:38 +0000133 */
134 xlat_table (NOLOAD) : {
135 *(xlat_table)
136 } >RAM
137
Soby Mathew2ae20432015-01-08 18:02:44 +0000138#if USE_COHERENT_MEM
Achin Guptaa0cd9892014-02-09 13:30:38 +0000139 /*
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000140 * The base address of the coherent memory section must be page-aligned (4K)
141 * to guarantee that the coherent data are stored on their own pages and
142 * are not mixed with normal data. This is required to set up the correct
143 * memory attributes for the coherent data page tables.
144 */
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +0000145 coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000146 __COHERENT_RAM_START__ = .;
147 *(tzfw_coherent_mem)
148 __COHERENT_RAM_END_UNALIGNED__ = .;
149 /*
150 * Memory page(s) mapped to this section will be marked
151 * as device memory. No other unexpected data must creep in.
152 * Ensure the rest of the current memory page is unused.
153 */
Roberto Vargasd93fde32018-04-11 11:53:31 +0100154 . = ALIGN(PAGE_SIZE);
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000155 __COHERENT_RAM_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100156 } >RAM
Soby Mathew2ae20432015-01-08 18:02:44 +0000157#endif
Achin Gupta4f6ad662013-10-25 09:08:21 +0100158
Achin Guptae9c4a642015-09-11 16:03:13 +0100159 /*
160 * Define a linker symbol to mark end of the RW memory area for this
161 * image.
162 */
163 __RW_END__ = .;
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000164 __BL2_END__ = .;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100165
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000166 __BSS_SIZE__ = SIZEOF(.bss);
Soby Mathew2ae20432015-01-08 18:02:44 +0000167
168#if USE_COHERENT_MEM
Sandrine Bailleux8d69a032013-11-27 09:38:52 +0000169 __COHERENT_RAM_UNALIGNED_SIZE__ =
170 __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
Soby Mathew2ae20432015-01-08 18:02:44 +0000171#endif
Sandrine Bailleux6c8b3592014-05-22 15:28:26 +0100172
173 ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
Achin Gupta4f6ad662013-10-25 09:08:21 +0100174}