blob: 8d4984fbf87c4c30179d7d9067296df819d9bb3c [file] [log] [blame]
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01001/*
Antonio Nino Diaz7c2a3ca2018-02-23 15:07:54 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +01005 */
6
7#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
9#include <lib/xlat_tables/xlat_tables_defs.h>
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010010
11OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
12OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
13ENTRY(bl2u_entrypoint)
14
15MEMORY {
16 RAM (rwx): ORIGIN = BL2U_BASE, LENGTH = BL2U_LIMIT - BL2U_BASE
17}
18
19
20SECTIONS
21{
22 . = BL2U_BASE;
Antonio Nino Diaz2ce2b092017-11-15 11:45:35 +000023 ASSERT(. == ALIGN(PAGE_SIZE),
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010024 "BL2U_BASE address is not aligned on a page boundary.")
25
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010026#if SEPARATE_CODE_AND_RODATA
27 .text . : {
28 __TEXT_START__ = .;
29 *bl2u_entrypoint.o(.text*)
30 *(.text*)
31 *(.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__ = .;
47 *(.rodata*)
Roberto Vargasd93fde32018-04-11 11:53:31 +010048 . = ALIGN(PAGE_SIZE);
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010049 __RODATA_END__ = .;
50 } >RAM
51#else
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010052 ro . : {
53 __RO_START__ = .;
54 *bl2u_entrypoint.o(.text*)
55 *(.text*)
56 *(.rodata*)
57
58 *(.vectors)
59 __RO_END_UNALIGNED__ = .;
60 /*
61 * Memory page(s) mapped to this section will be marked as
62 * read-only, executable. No RW data from the next section must
63 * creep in. Ensure the rest of the current memory page is unused.
64 */
Roberto Vargasd93fde32018-04-11 11:53:31 +010065 . = ALIGN(PAGE_SIZE);
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010066 __RO_END__ = .;
67 } >RAM
Sandrine Bailleuxf91f1442016-07-08 14:37:40 +010068#endif
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010069
70 /*
71 * Define a linker symbol to mark start of the RW memory area for this
72 * image.
73 */
74 __RW_START__ = . ;
75
Douglas Raillard306593d2017-02-24 18:14:15 +000076 /*
77 * .data must be placed at a lower address than the stacks if the stack
78 * protector is enabled. Alternatively, the .data.stack_protector_canary
79 * section can be placed independently of the main .data section.
80 */
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010081 .data . : {
82 __DATA_START__ = .;
83 *(.data*)
84 __DATA_END__ = .;
85 } >RAM
86
87 stacks (NOLOAD) : {
88 __STACKS_START__ = .;
89 *(tzfw_normal_stacks)
90 __STACKS_END__ = .;
91 } >RAM
92
93 /*
94 * The .bss section gets initialised to 0 at runtime.
Douglas Raillard21362a92016-12-02 13:51:54 +000095 * Its base address should be 16-byte aligned for better performance of the
96 * zero-initialization code.
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +010097 */
98 .bss : ALIGN(16) {
99 __BSS_START__ = .;
100 *(SORT_BY_ALIGNMENT(.bss*))
101 *(COMMON)
102 __BSS_END__ = .;
103 } >RAM
104
105 /*
106 * The xlat_table section is for full, aligned page tables (4K).
107 * Removing them from .bss avoids forcing 4K alignment on
Antonio Nino Diaz7c2a3ca2018-02-23 15:07:54 +0000108 * the .bss section. The tables are initialized to zero by the translation
109 * tables library.
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +0100110 */
111 xlat_table (NOLOAD) : {
112 *(xlat_table)
113 } >RAM
114
115#if USE_COHERENT_MEM
116 /*
117 * 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) {
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +0100123 __COHERENT_RAM_START__ = .;
124 *(tzfw_coherent_mem)
125 __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);
Yatharth Kocharb1c2fe02015-10-14 15:27:24 +0100132 __COHERENT_RAM_END__ = .;
133 } >RAM
134#endif
135
136 /*
137 * Define a linker symbol to mark end of the RW memory area for this
138 * image.
139 */
140 __RW_END__ = .;
141 __BL2U_END__ = .;
142
143 __BSS_SIZE__ = SIZEOF(.bss);
144
145 ASSERT(. <= BL2U_LIMIT, "BL2U image has exceeded its limit.")
146}