xref: /rk3399_ARM-atf/bl2/bl2.ld.S (revision f6088168f0608604bc1cd57d8ab52d848fdb835b)
14f6ad66aSAchin Gupta/*
2da04341eSChris Kay * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
34f6ad66aSAchin Gupta *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
54f6ad66aSAchin Gupta */
64f6ad66aSAchin Gupta
7665e71b8SMasahiro Yamada#include <common/bl_common.ld.h>
809d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
94f6ad66aSAchin Gupta
104f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
114f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
129f98aa1aSJeenu ViswambharanENTRY(bl2_entrypoint)
134f6ad66aSAchin Gupta
144f6ad66aSAchin GuptaMEMORY {
15d7fbf132SJuan Castillo    RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE
164f6ad66aSAchin Gupta}
174f6ad66aSAchin Gupta
18f90fe02fSChris KaySECTIONS {
19*f6088168SHarrison Mutai    RAM_REGION_START = ORIGIN(RAM);
20*f6088168SHarrison Mutai    RAM_REGION_LENGTH = LENGTH(RAM);
214f6ad66aSAchin Gupta    . = BL2_BASE;
22f90fe02fSChris Kay
23a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
248d69a03fSSandrine Bailleux        "BL2_BASE address is not aligned on a page boundary.")
254f6ad66aSAchin Gupta
265d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA
275d1c104fSSandrine Bailleux    .text . : {
285d1c104fSSandrine Bailleux        __TEXT_START__ = .;
29f90fe02fSChris Kay
306c09af9fSZelalem Aweke#if ENABLE_RME
316c09af9fSZelalem Aweke        *bl2_rme_entrypoint.o(.text*)
326c09af9fSZelalem Aweke#else /* ENABLE_RME */
335d1c104fSSandrine Bailleux        *bl2_entrypoint.o(.text*)
346c09af9fSZelalem Aweke#endif /* ENABLE_RME */
35f90fe02fSChris Kay
36ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
375d1c104fSSandrine Bailleux        *(.vectors)
38f90fe02fSChris Kay
395629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
40f90fe02fSChris Kay
415d1c104fSSandrine Bailleux        __TEXT_END__ = .;
425d1c104fSSandrine Bailleux    } >RAM
435d1c104fSSandrine Bailleux
44f90fe02fSChris Kay    /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
45ad925094SRoberto Vargas    .ARM.extab . : {
46ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
47ad925094SRoberto Vargas    } >RAM
48ad925094SRoberto Vargas
49ad925094SRoberto Vargas    .ARM.exidx . : {
50ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
51ad925094SRoberto Vargas    } >RAM
52ad925094SRoberto Vargas
535d1c104fSSandrine Bailleux    .rodata . : {
545d1c104fSSandrine Bailleux        __RODATA_START__ = .;
55f90fe02fSChris Kay
56ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
575d1c104fSSandrine Bailleux
580a0a7a9aSMasahiro Yamada        RODATA_COMMON
595d1c104fSSandrine Bailleux
605629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
61f90fe02fSChris Kay
625d1c104fSSandrine Bailleux        __RODATA_END__ = .;
635d1c104fSSandrine Bailleux    } >RAM
64f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */
65da04341eSChris Kay    .ro . : {
668d69a03fSSandrine Bailleux        __RO_START__ = .;
67f90fe02fSChris Kay
68dccc537aSAndrew Thoelke        *bl2_entrypoint.o(.text*)
69ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
70ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
7105799ae0SJuan Castillo
720a0a7a9aSMasahiro Yamada        RODATA_COMMON
7305799ae0SJuan Castillo
74b739f22aSAchin Gupta        *(.vectors)
75f90fe02fSChris Kay
768d69a03fSSandrine Bailleux        __RO_END_UNALIGNED__ = .;
774f6ad66aSAchin Gupta
7854dc71e7SAchin Gupta        /*
79f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as read-only,
80f90fe02fSChris Kay         * executable. No RW data from the next section must creep in. Ensure
81f90fe02fSChris Kay         * that the rest of the current memory page is unused.
8254dc71e7SAchin Gupta         */
83f90fe02fSChris Kay        . = ALIGN(PAGE_SIZE);
84f90fe02fSChris Kay
85f90fe02fSChris Kay        __RO_END__ = .;
86f90fe02fSChris Kay    } >RAM
87f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */
88f90fe02fSChris Kay
8954dc71e7SAchin Gupta    __RW_START__ = .;
9054dc71e7SAchin Gupta
91caa3e7e0SMasahiro Yamada    DATA_SECTION >RAM
92a926a9f6SMasahiro Yamada    STACK_SECTION >RAM
93a7739bc7SMasahiro Yamada    BSS_SECTION >RAM
94665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
95a0cd989dSAchin Gupta
96ab8707e6SSoby Mathew#if USE_COHERENT_MEM
97a0cd989dSAchin Gupta    /*
98f90fe02fSChris Kay     * The base address of the coherent memory section must be page-aligned to
99f90fe02fSChris Kay     * guarantee that the coherent data are stored on their own pages and are
100f90fe02fSChris Kay     * not mixed with normal data.  This is required to set up the correct
1018d69a03fSSandrine Bailleux     * memory attributes for the coherent data page tables.
1028d69a03fSSandrine Bailleux     */
103da04341eSChris Kay    .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
1048d69a03fSSandrine Bailleux        __COHERENT_RAM_START__ = .;
105da04341eSChris Kay        *(.tzfw_coherent_mem)
1068d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ = .;
1074f6ad66aSAchin Gupta
10854dc71e7SAchin Gupta        /*
109f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as device
110f90fe02fSChris Kay         * memory. No other unexpected data must creep in. Ensure the rest of
111f90fe02fSChris Kay         * the current memory page is unused.
11254dc71e7SAchin Gupta         */
113f90fe02fSChris Kay        . = ALIGN(PAGE_SIZE);
114f90fe02fSChris Kay
115f90fe02fSChris Kay        __COHERENT_RAM_END__ = .;
116f90fe02fSChris Kay    } >RAM
117f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
118f90fe02fSChris Kay
11954dc71e7SAchin Gupta    __RW_END__ = .;
1208d69a03fSSandrine Bailleux    __BL2_END__ = .;
121*f6088168SHarrison Mutai    RAM_REGION_END = .;
1224f6ad66aSAchin Gupta
1238d69a03fSSandrine Bailleux    __BSS_SIZE__ = SIZEOF(.bss);
124ab8707e6SSoby Mathew
125ab8707e6SSoby Mathew#if USE_COHERENT_MEM
1268d69a03fSSandrine Bailleux    __COHERENT_RAM_UNALIGNED_SIZE__ =
1278d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
128f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
129a37255a2SSandrine Bailleux
130a37255a2SSandrine Bailleux    ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
1314f6ad66aSAchin Gupta}
132