blob: ee6a0206594dfcd52473c5752697ab2e461bd2b4 [file] [log] [blame]
Yatharth Kochar9003fa02015-10-14 15:27:24 +01001/*
Chris Kayda043412023-02-14 11:30:04 +00002 * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
Yatharth Kochar9003fa02015-10-14 15:27:24 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kochar9003fa02015-10-14 15:27:24 +01005 */
6
7#include <platform_def.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00008
Masahiro Yamada665e71b2020-03-09 17:39:48 +09009#include <common/bl_common.ld.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000010#include <lib/xlat_tables/xlat_tables_defs.h>
Yatharth Kochar9003fa02015-10-14 15:27:24 +010011
12OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
13OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
14ENTRY(bl2u_entrypoint)
15
16MEMORY {
17 RAM (rwx): ORIGIN = BL2U_BASE, LENGTH = BL2U_LIMIT - BL2U_BASE
18}
19
Chris Kayf90fe022022-09-29 14:36:53 +010020SECTIONS {
Harrison Mutaif6088162023-04-19 10:08:56 +010021 RAM_REGION_START = ORIGIN(RAM);
22 RAM_REGION_LENGTH = LENGTH(RAM);
Yatharth Kochar9003fa02015-10-14 15:27:24 +010023 . = BL2U_BASE;
Chris Kayf90fe022022-09-29 14:36:53 +010024
Antonio Nino Diaza2aedac2017-11-15 11:45:35 +000025 ASSERT(. == ALIGN(PAGE_SIZE),
Chris Kayf90fe022022-09-29 14:36:53 +010026 "BL2U_BASE address is not aligned on a page boundary.")
Yatharth Kochar9003fa02015-10-14 15:27:24 +010027
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010028#if SEPARATE_CODE_AND_RODATA
29 .text . : {
Andrey Skvortsov3d6edc32023-09-05 22:09:25 +030030 ASSERT(. == ALIGN(PAGE_SIZE),
31 ".text address is not aligned on a page boundary.");
32
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010033 __TEXT_START__ = .;
Chris Kayf90fe022022-09-29 14:36:53 +010034
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010035 *bl2u_entrypoint.o(.text*)
Samuel Hollandebd6efa2019-10-20 16:11:25 -050036 *(SORT_BY_ALIGNMENT(.text*))
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010037 *(.vectors)
Michal Simekf7d445f2023-04-27 14:26:03 +020038 __TEXT_END_UNALIGNED__ = .;
Chris Kayf90fe022022-09-29 14:36:53 +010039
Roberto Vargas5629b2b2018-04-11 11:53:31 +010040 . = ALIGN(PAGE_SIZE);
Chris Kayf90fe022022-09-29 14:36:53 +010041
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010042 __TEXT_END__ = .;
Chris Kayf90fe022022-09-29 14:36:53 +010043 } >RAM
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010044
Chris Kayf90fe022022-09-29 14:36:53 +010045 /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
46 .ARM.extab . : {
Roberto Vargasad925092018-05-10 11:01:16 +010047 *(.ARM.extab* .gnu.linkonce.armextab.*)
Chris Kayf90fe022022-09-29 14:36:53 +010048 } >RAM
Roberto Vargasad925092018-05-10 11:01:16 +010049
Chris Kayf90fe022022-09-29 14:36:53 +010050 .ARM.exidx . : {
Roberto Vargasad925092018-05-10 11:01:16 +010051 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
Chris Kayf90fe022022-09-29 14:36:53 +010052 } >RAM
Roberto Vargasad925092018-05-10 11:01:16 +010053
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010054 .rodata . : {
55 __RODATA_START__ = .;
Samuel Hollandebd6efa2019-10-20 16:11:25 -050056 *(SORT_BY_ALIGNMENT(.rodata*))
Masahiro Yamada0a0a7a92020-03-26 10:57:12 +090057
Chris Kayf90fe022022-09-29 14:36:53 +010058 RODATA_COMMON
Masahiro Yamada0a0a7a92020-03-26 10:57:12 +090059
Michal Simekf7d445f2023-04-27 14:26:03 +020060 __RODATA_END_UNALIGNED__ = .;
Roberto Vargas5629b2b2018-04-11 11:53:31 +010061 . = ALIGN(PAGE_SIZE);
Sandrine Bailleux5d1c1042016-07-08 14:37:40 +010062 __RODATA_END__ = .;
63 } >RAM
Chris Kayf90fe022022-09-29 14:36:53 +010064#else /* SEPARATE_CODE_AND_RODATA */
Chris Kayda043412023-02-14 11:30:04 +000065 .ro . : {
Andrey Skvortsov3d6edc32023-09-05 22:09:25 +030066 ASSERT(. == ALIGN(PAGE_SIZE),
67 ".ro address is not aligned on a page boundary.");
68
Yatharth Kochar9003fa02015-10-14 15:27:24 +010069 __RO_START__ = .;
Chris Kayf90fe022022-09-29 14:36:53 +010070
Yatharth Kochar9003fa02015-10-14 15:27:24 +010071 *bl2u_entrypoint.o(.text*)
Samuel Hollandebd6efa2019-10-20 16:11:25 -050072 *(SORT_BY_ALIGNMENT(.text*))
73 *(SORT_BY_ALIGNMENT(.rodata*))
Yatharth Kochar9003fa02015-10-14 15:27:24 +010074
Chris Kayf90fe022022-09-29 14:36:53 +010075 RODATA_COMMON
Masahiro Yamada0a0a7a92020-03-26 10:57:12 +090076
Yatharth Kochar9003fa02015-10-14 15:27:24 +010077 *(.vectors)
Chris Kayf90fe022022-09-29 14:36:53 +010078
Yatharth Kochar9003fa02015-10-14 15:27:24 +010079 __RO_END_UNALIGNED__ = .;
Chris Kayf90fe022022-09-29 14:36:53 +010080
Yatharth Kochar9003fa02015-10-14 15:27:24 +010081 /*
Chris Kayf90fe022022-09-29 14:36:53 +010082 * Memory page(s) mapped to this section will be marked as read-only,
83 * executable. No RW data from the next section must creep in. Ensure
84 * that the rest of the current memory page is unused.
Yatharth Kochar9003fa02015-10-14 15:27:24 +010085 */
Roberto Vargas5629b2b2018-04-11 11:53:31 +010086 . = ALIGN(PAGE_SIZE);
Chris Kayf90fe022022-09-29 14:36:53 +010087
Yatharth Kochar9003fa02015-10-14 15:27:24 +010088 __RO_END__ = .;
89 } >RAM
Chris Kayf90fe022022-09-29 14:36:53 +010090#endif /* SEPARATE_CODE_AND_RODATA */
Yatharth Kochar9003fa02015-10-14 15:27:24 +010091
Chris Kayf90fe022022-09-29 14:36:53 +010092 __RW_START__ = .;
Yatharth Kochar9003fa02015-10-14 15:27:24 +010093
Masahiro Yamadacaa3e7e2020-04-22 10:50:12 +090094 DATA_SECTION >RAM
Masahiro Yamadaa926a9f2020-04-07 13:04:24 +090095 STACK_SECTION >RAM
Masahiro Yamadaa7739bc2020-03-26 13:16:33 +090096 BSS_SECTION >RAM
Masahiro Yamada665e71b2020-03-09 17:39:48 +090097 XLAT_TABLE_SECTION >RAM
Yatharth Kochar9003fa02015-10-14 15:27:24 +010098
99#if USE_COHERENT_MEM
100 /*
Chris Kayf90fe022022-09-29 14:36:53 +0100101 * The base address of the coherent memory section must be page-aligned to
102 * guarantee that the coherent data are stored on their own pages and are
103 * not mixed with normal data. This is required to set up the correct
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100104 * memory attributes for the coherent data page tables.
105 */
Chris Kayda043412023-02-14 11:30:04 +0000106 .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100107 __COHERENT_RAM_START__ = .;
Chris Kayda043412023-02-14 11:30:04 +0000108 *(.tzfw_coherent_mem)
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100109 __COHERENT_RAM_END_UNALIGNED__ = .;
Chris Kayf90fe022022-09-29 14:36:53 +0100110
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100111 /*
Chris Kayf90fe022022-09-29 14:36:53 +0100112 * Memory page(s) mapped to this section will be marked as device
113 * memory. No other unexpected data must creep in. Ensure the rest of
114 * the current memory page is unused.
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100115 */
Roberto Vargas5629b2b2018-04-11 11:53:31 +0100116 . = ALIGN(PAGE_SIZE);
Chris Kayf90fe022022-09-29 14:36:53 +0100117
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100118 __COHERENT_RAM_END__ = .;
119 } >RAM
Chris Kayf90fe022022-09-29 14:36:53 +0100120#endif /* USE_COHERENT_MEM */
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100121
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100122 __RW_END__ = .;
123 __BL2U_END__ = .;
124
125 __BSS_SIZE__ = SIZEOF(.bss);
126
127 ASSERT(. <= BL2U_LIMIT, "BL2U image has exceeded its limit.")
Harrison Mutaif6088162023-04-19 10:08:56 +0100128 RAM_REGION_END = .;
Yatharth Kochar9003fa02015-10-14 15:27:24 +0100129}