xref: /rk3399_ARM-atf/bl2u/bl2u.ld.S (revision f6088168f0608604bc1cd57d8ab52d848fdb835b)
19003fa0bSYatharth Kochar/*
2da04341eSChris Kay * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
39003fa0bSYatharth Kochar *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
59003fa0bSYatharth Kochar */
69003fa0bSYatharth Kochar
79003fa0bSYatharth Kochar#include <platform_def.h>
809d40e0eSAntonio Nino Diaz
9665e71b8SMasahiro Yamada#include <common/bl_common.ld.h>
1009d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
119003fa0bSYatharth Kochar
129003fa0bSYatharth KocharOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
139003fa0bSYatharth KocharOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
149003fa0bSYatharth KocharENTRY(bl2u_entrypoint)
159003fa0bSYatharth Kochar
169003fa0bSYatharth KocharMEMORY {
179003fa0bSYatharth Kochar    RAM (rwx): ORIGIN = BL2U_BASE, LENGTH = BL2U_LIMIT - BL2U_BASE
189003fa0bSYatharth Kochar}
199003fa0bSYatharth Kochar
20f90fe02fSChris KaySECTIONS {
21*f6088168SHarrison Mutai    RAM_REGION_START = ORIGIN(RAM);
22*f6088168SHarrison Mutai    RAM_REGION_LENGTH = LENGTH(RAM);
239003fa0bSYatharth Kochar    . = BL2U_BASE;
24f90fe02fSChris Kay
25a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
269003fa0bSYatharth Kochar        "BL2U_BASE address is not aligned on a page boundary.")
279003fa0bSYatharth Kochar
285d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA
295d1c104fSSandrine Bailleux    .text . : {
305d1c104fSSandrine Bailleux        __TEXT_START__ = .;
31f90fe02fSChris Kay
325d1c104fSSandrine Bailleux        *bl2u_entrypoint.o(.text*)
33ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
345d1c104fSSandrine Bailleux        *(.vectors)
35f90fe02fSChris Kay
365629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
37f90fe02fSChris Kay
385d1c104fSSandrine Bailleux        __TEXT_END__ = .;
395d1c104fSSandrine Bailleux    } >RAM
405d1c104fSSandrine Bailleux
41f90fe02fSChris Kay    /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
42ad925094SRoberto Vargas    .ARM.extab . : {
43ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
44ad925094SRoberto Vargas    } >RAM
45ad925094SRoberto Vargas
46ad925094SRoberto Vargas    .ARM.exidx . : {
47ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
48ad925094SRoberto Vargas    } >RAM
49ad925094SRoberto Vargas
505d1c104fSSandrine Bailleux    .rodata . : {
515d1c104fSSandrine Bailleux        __RODATA_START__ = .;
52ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
530a0a7a9aSMasahiro Yamada
540a0a7a9aSMasahiro Yamada        RODATA_COMMON
550a0a7a9aSMasahiro Yamada
565629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
575d1c104fSSandrine Bailleux        __RODATA_END__ = .;
585d1c104fSSandrine Bailleux    } >RAM
59f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */
60da04341eSChris Kay    .ro . : {
619003fa0bSYatharth Kochar        __RO_START__ = .;
62f90fe02fSChris Kay
639003fa0bSYatharth Kochar        *bl2u_entrypoint.o(.text*)
64ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
65ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
669003fa0bSYatharth Kochar
670a0a7a9aSMasahiro Yamada        RODATA_COMMON
680a0a7a9aSMasahiro Yamada
699003fa0bSYatharth Kochar        *(.vectors)
70f90fe02fSChris Kay
719003fa0bSYatharth Kochar        __RO_END_UNALIGNED__ = .;
729003fa0bSYatharth Kochar
739003fa0bSYatharth Kochar        /*
74f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as read-only,
75f90fe02fSChris Kay         * executable. No RW data from the next section must creep in. Ensure
76f90fe02fSChris Kay         * that the rest of the current memory page is unused.
779003fa0bSYatharth Kochar         */
78f90fe02fSChris Kay        . = ALIGN(PAGE_SIZE);
79f90fe02fSChris Kay
80f90fe02fSChris Kay        __RO_END__ = .;
81f90fe02fSChris Kay    } >RAM
82f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */
83f90fe02fSChris Kay
849003fa0bSYatharth Kochar    __RW_START__ = .;
859003fa0bSYatharth Kochar
86caa3e7e0SMasahiro Yamada    DATA_SECTION >RAM
87a926a9f6SMasahiro Yamada    STACK_SECTION >RAM
88a7739bc7SMasahiro Yamada    BSS_SECTION >RAM
89665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
909003fa0bSYatharth Kochar
919003fa0bSYatharth Kochar#if USE_COHERENT_MEM
929003fa0bSYatharth Kochar    /*
93f90fe02fSChris Kay     * The base address of the coherent memory section must be page-aligned to
94f90fe02fSChris Kay     * guarantee that the coherent data are stored on their own pages and are
95f90fe02fSChris Kay     * not mixed with normal data.  This is required to set up the correct
969003fa0bSYatharth Kochar     * memory attributes for the coherent data page tables.
979003fa0bSYatharth Kochar     */
98da04341eSChris Kay    .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
999003fa0bSYatharth Kochar        __COHERENT_RAM_START__ = .;
100da04341eSChris Kay        *(.tzfw_coherent_mem)
1019003fa0bSYatharth Kochar        __COHERENT_RAM_END_UNALIGNED__ = .;
1029003fa0bSYatharth Kochar
1039003fa0bSYatharth Kochar        /*
104f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as device
105f90fe02fSChris Kay         * memory. No other unexpected data must creep in. Ensure the rest of
106f90fe02fSChris Kay         * the current memory page is unused.
1079003fa0bSYatharth Kochar         */
108f90fe02fSChris Kay        . = ALIGN(PAGE_SIZE);
109f90fe02fSChris Kay
110f90fe02fSChris Kay        __COHERENT_RAM_END__ = .;
111f90fe02fSChris Kay    } >RAM
112f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
113f90fe02fSChris Kay
1149003fa0bSYatharth Kochar    __RW_END__ = .;
1159003fa0bSYatharth Kochar    __BL2U_END__ = .;
1169003fa0bSYatharth Kochar
1179003fa0bSYatharth Kochar    __BSS_SIZE__ = SIZEOF(.bss);
1189003fa0bSYatharth Kochar
1199003fa0bSYatharth Kochar    ASSERT(. <= BL2U_LIMIT, "BL2U image has exceeded its limit.")
120*f6088168SHarrison Mutai    RAM_REGION_END = .;
1219003fa0bSYatharth Kochar}
122