xref: /rk3399_ARM-atf/bl2/bl2.ld.S (revision a926a9f60aa94a034b0a06eed296996363245d30)
14f6ad66aSAchin Gupta/*
2ab1981dbSLouis Mayencourt * Copyright (c) 2013-2020, 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
184f6ad66aSAchin Gupta
194f6ad66aSAchin GuptaSECTIONS
204f6ad66aSAchin Gupta{
214f6ad66aSAchin Gupta    . = BL2_BASE;
22a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
238d69a03fSSandrine Bailleux           "BL2_BASE address is not aligned on a page boundary.")
244f6ad66aSAchin Gupta
255d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA
265d1c104fSSandrine Bailleux    .text . : {
275d1c104fSSandrine Bailleux        __TEXT_START__ = .;
285d1c104fSSandrine Bailleux        *bl2_entrypoint.o(.text*)
29ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
305d1c104fSSandrine Bailleux        *(.vectors)
315629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
325d1c104fSSandrine Bailleux        __TEXT_END__ = .;
335d1c104fSSandrine Bailleux     } >RAM
345d1c104fSSandrine Bailleux
35ad925094SRoberto Vargas     /* .ARM.extab and .ARM.exidx are only added because Clang need them */
36ad925094SRoberto Vargas     .ARM.extab . : {
37ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
38ad925094SRoberto Vargas     } >RAM
39ad925094SRoberto Vargas
40ad925094SRoberto Vargas     .ARM.exidx . : {
41ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
42ad925094SRoberto Vargas     } >RAM
43ad925094SRoberto Vargas
445d1c104fSSandrine Bailleux    .rodata . : {
455d1c104fSSandrine Bailleux        __RODATA_START__ = .;
46ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
475d1c104fSSandrine Bailleux
480a0a7a9aSMasahiro Yamada	RODATA_COMMON
495d1c104fSSandrine Bailleux
505629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
515d1c104fSSandrine Bailleux        __RODATA_END__ = .;
525d1c104fSSandrine Bailleux    } >RAM
535d1c104fSSandrine Bailleux#else
548d69a03fSSandrine Bailleux    ro . : {
558d69a03fSSandrine Bailleux        __RO_START__ = .;
56dccc537aSAndrew Thoelke        *bl2_entrypoint.o(.text*)
57ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
58ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
5905799ae0SJuan Castillo
600a0a7a9aSMasahiro Yamada	RODATA_COMMON
6105799ae0SJuan Castillo
62b739f22aSAchin Gupta        *(.vectors)
638d69a03fSSandrine Bailleux        __RO_END_UNALIGNED__ = .;
648d69a03fSSandrine Bailleux        /*
658d69a03fSSandrine Bailleux         * Memory page(s) mapped to this section will be marked as
668d69a03fSSandrine Bailleux         * read-only, executable.  No RW data from the next section must
678d69a03fSSandrine Bailleux         * creep in.  Ensure the rest of the current memory page is unused.
688d69a03fSSandrine Bailleux         */
695629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
708d69a03fSSandrine Bailleux        __RO_END__ = .;
714f6ad66aSAchin Gupta    } >RAM
725d1c104fSSandrine Bailleux#endif
734f6ad66aSAchin Gupta
7454dc71e7SAchin Gupta    /*
7554dc71e7SAchin Gupta     * Define a linker symbol to mark start of the RW memory area for this
7654dc71e7SAchin Gupta     * image.
7754dc71e7SAchin Gupta     */
7854dc71e7SAchin Gupta    __RW_START__ = . ;
7954dc71e7SAchin Gupta
8051faada7SDouglas Raillard    /*
8151faada7SDouglas Raillard     * .data must be placed at a lower address than the stacks if the stack
8251faada7SDouglas Raillard     * protector is enabled. Alternatively, the .data.stack_protector_canary
8351faada7SDouglas Raillard     * section can be placed independently of the main .data section.
8451faada7SDouglas Raillard     */
858d69a03fSSandrine Bailleux    .data . : {
868d69a03fSSandrine Bailleux        __DATA_START__ = .;
87ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.data*))
888d69a03fSSandrine Bailleux        __DATA_END__ = .;
898d69a03fSSandrine Bailleux    } >RAM
908d69a03fSSandrine Bailleux
91*a926a9f6SMasahiro Yamada    STACK_SECTION >RAM
92a7739bc7SMasahiro Yamada    BSS_SECTION >RAM
93665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
94a0cd989dSAchin Gupta
95ab8707e6SSoby Mathew#if USE_COHERENT_MEM
96a0cd989dSAchin Gupta    /*
978d69a03fSSandrine Bailleux     * The base address of the coherent memory section must be page-aligned (4K)
988d69a03fSSandrine Bailleux     * to guarantee that the coherent data are stored on their own pages and
998d69a03fSSandrine Bailleux     * are not mixed with normal data.  This is required to set up the correct
1008d69a03fSSandrine Bailleux     * memory attributes for the coherent data page tables.
1018d69a03fSSandrine Bailleux     */
102a2aedac2SAntonio Nino Diaz    coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
1038d69a03fSSandrine Bailleux        __COHERENT_RAM_START__ = .;
1048d69a03fSSandrine Bailleux        *(tzfw_coherent_mem)
1058d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ = .;
1068d69a03fSSandrine Bailleux        /*
1078d69a03fSSandrine Bailleux         * Memory page(s) mapped to this section will be marked
1088d69a03fSSandrine Bailleux         * as device memory.  No other unexpected data must creep in.
1098d69a03fSSandrine Bailleux         * Ensure the rest of the current memory page is unused.
1108d69a03fSSandrine Bailleux         */
1115629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
1128d69a03fSSandrine Bailleux        __COHERENT_RAM_END__ = .;
1134f6ad66aSAchin Gupta    } >RAM
114ab8707e6SSoby Mathew#endif
1154f6ad66aSAchin Gupta
11654dc71e7SAchin Gupta    /*
11754dc71e7SAchin Gupta     * Define a linker symbol to mark end of the RW memory area for this
11854dc71e7SAchin Gupta     * image.
11954dc71e7SAchin Gupta     */
12054dc71e7SAchin Gupta    __RW_END__ = .;
1218d69a03fSSandrine Bailleux    __BL2_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__;
128ab8707e6SSoby Mathew#endif
129a37255a2SSandrine Bailleux
130a37255a2SSandrine Bailleux    ASSERT(. <= BL2_LIMIT, "BL2 image has exceeded its limit.")
1314f6ad66aSAchin Gupta}
132