xref: /rk3399_ARM-atf/bl1/bl1.ld.S (revision f7d445fcbbd3d5146d95698ace3381fcf522b9af)
14f6ad66aSAchin Gupta/*
25e7e8bfaSHarrison Mutai * 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
7caa3e7e0SMasahiro Yamada/*
8f90fe02fSChris Kay * The .data section gets copied from ROM to RAM at runtime. Its LMA should be
9f90fe02fSChris Kay * 16-byte aligned to allow efficient copying of 16-bytes aligned regions in it.
10caa3e7e0SMasahiro Yamada * Its VMA must be page-aligned as it marks the first read/write page.
11caa3e7e0SMasahiro Yamada */
12caa3e7e0SMasahiro Yamada#define DATA_ALIGN	16
13caa3e7e0SMasahiro Yamada
14665e71b8SMasahiro Yamada#include <common/bl_common.ld.h>
1509d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
164f6ad66aSAchin Gupta
174f6ad66aSAchin GuptaOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
184f6ad66aSAchin GuptaOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
199f98aa1aSJeenu ViswambharanENTRY(bl1_entrypoint)
204f6ad66aSAchin Gupta
214f6ad66aSAchin GuptaMEMORY {
22d7fbf132SJuan Castillo    ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
23d7fbf132SJuan Castillo    RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
244f6ad66aSAchin Gupta}
254f6ad66aSAchin Gupta
26f90fe02fSChris KaySECTIONS {
275e7e8bfaSHarrison Mutai    ROM_REGION_START = ORIGIN(ROM);
285e7e8bfaSHarrison Mutai    ROM_REGION_LENGTH = LENGTH(ROM);
295e7e8bfaSHarrison Mutai    RAM_REGION_START = ORIGIN(RAM);
305e7e8bfaSHarrison Mutai    RAM_REGION_LENGTH = LENGTH(RAM);
315e7e8bfaSHarrison Mutai
324f59d835SSandrine Bailleux    . = BL1_RO_BASE;
33f90fe02fSChris Kay
34a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
354f59d835SSandrine Bailleux        "BL1_RO_BASE address is not aligned on a page boundary.")
364f59d835SSandrine Bailleux
375d1c104fSSandrine Bailleux#if SEPARATE_CODE_AND_RODATA
385d1c104fSSandrine Bailleux    .text . : {
395d1c104fSSandrine Bailleux        __TEXT_START__ = .;
40f90fe02fSChris Kay
415d1c104fSSandrine Bailleux        *bl1_entrypoint.o(.text*)
42ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
435d1c104fSSandrine Bailleux        *(.vectors)
44*f7d445fcSMichal Simek        __TEXT_END_UNALIGNED__ = .;
45f90fe02fSChris Kay
465629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
47f90fe02fSChris Kay
485d1c104fSSandrine Bailleux        __TEXT_END__ = .;
495d1c104fSSandrine Bailleux    } >ROM
505d1c104fSSandrine Bailleux
51f90fe02fSChris Kay    /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
52ad925094SRoberto Vargas    .ARM.extab . : {
53ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
54ad925094SRoberto Vargas    } >ROM
55ad925094SRoberto Vargas
56ad925094SRoberto Vargas    .ARM.exidx . : {
57ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
58ad925094SRoberto Vargas    } >ROM
59ad925094SRoberto Vargas
605d1c104fSSandrine Bailleux    .rodata . : {
615d1c104fSSandrine Bailleux        __RODATA_START__ = .;
62f90fe02fSChris Kay
63ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
645d1c104fSSandrine Bailleux
650a0a7a9aSMasahiro Yamada        RODATA_COMMON
665d1c104fSSandrine Bailleux
675d1c104fSSandrine Bailleux        /*
685d1c104fSSandrine Bailleux         * No need to pad out the .rodata section to a page boundary. Next is
695d1c104fSSandrine Bailleux         * the .data section, which can mapped in ROM with the same memory
705d1c104fSSandrine Bailleux         * attributes as the .rodata section.
7141286590SArve Hjønnevåg         *
72f90fe02fSChris Kay         * Pad out to 16 bytes though as .data section needs to be 16-byte
73f90fe02fSChris Kay         * aligned and lld does not align the LMA to the alignment specified
7441286590SArve Hjønnevåg         * on the .data section.
755d1c104fSSandrine Bailleux         */
76*f7d445fcSMichal Simek        __RODATA_END_UNALIGNED__ = .;
775d1c104fSSandrine Bailleux        __RODATA_END__ = .;
78f90fe02fSChris Kay
7941286590SArve Hjønnevåg        . = ALIGN(16);
805d1c104fSSandrine Bailleux    } >ROM
81f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */
82da04341eSChris Kay    .ro . : {
838d69a03fSSandrine Bailleux        __RO_START__ = .;
84f90fe02fSChris Kay
85dccc537aSAndrew Thoelke        *bl1_entrypoint.o(.text*)
86ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.text*))
87ebd6efaeSSamuel Holland        *(SORT_BY_ALIGNMENT(.rodata*))
889b476841SSoby Mathew
890a0a7a9aSMasahiro Yamada        RODATA_COMMON
909b476841SSoby Mathew
91b739f22aSAchin Gupta        *(.vectors)
92f90fe02fSChris Kay
938d69a03fSSandrine Bailleux        __RO_END__ = .;
9441286590SArve Hjønnevåg
9541286590SArve Hjønnevåg        /*
96f90fe02fSChris Kay         * Pad out to 16 bytes as the .data section needs to be 16-byte aligned
97f90fe02fSChris Kay         * and lld does not align the LMA to the alignment specified on the
98f90fe02fSChris Kay         * .data section.
9941286590SArve Hjønnevåg         */
10041286590SArve Hjønnevåg        . = ALIGN(16);
1014f6ad66aSAchin Gupta    } >ROM
102f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */
1034f6ad66aSAchin Gupta
1049b476841SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
1059b476841SSoby Mathew        "cpu_ops not defined for this platform.")
1069b476841SSoby Mathew
1075e7e8bfaSHarrison Mutai    ROM_REGION_END = .;
10851faada7SDouglas Raillard    . = BL1_RW_BASE;
109f90fe02fSChris Kay
110a2aedac2SAntonio Nino Diaz    ASSERT(BL1_RW_BASE == ALIGN(PAGE_SIZE),
11151faada7SDouglas Raillard        "BL1_RW_BASE address is not aligned on a page boundary.")
11251faada7SDouglas Raillard
113caa3e7e0SMasahiro Yamada    DATA_SECTION >RAM AT>ROM
114f90fe02fSChris Kay
115caa3e7e0SMasahiro Yamada    __DATA_RAM_START__ = __DATA_START__;
116caa3e7e0SMasahiro Yamada    __DATA_RAM_END__ = __DATA_END__;
1174f6ad66aSAchin Gupta
118a926a9f6SMasahiro Yamada    STACK_SECTION >RAM
119a7739bc7SMasahiro Yamada    BSS_SECTION >RAM
120665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
12174cbb839SJeenu Viswambharan
122ab8707e6SSoby Mathew#if USE_COHERENT_MEM
12374cbb839SJeenu Viswambharan    /*
124f90fe02fSChris Kay     * The base address of the coherent memory section must be page-aligned to
125f90fe02fSChris Kay     * guarantee that the coherent data are stored on their own pages and are
126f90fe02fSChris Kay     * not mixed with normal data. This is required to set up the correct memory
127f90fe02fSChris Kay     * attributes for the coherent data page tables.
1288d69a03fSSandrine Bailleux     */
129da04341eSChris Kay    .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
1308d69a03fSSandrine Bailleux        __COHERENT_RAM_START__ = .;
131da04341eSChris Kay        *(.tzfw_coherent_mem)
1328d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ = .;
133f90fe02fSChris Kay
1348d69a03fSSandrine Bailleux        /*
135f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as device
136f90fe02fSChris Kay         * memory. No other unexpected data must creep in. Ensure the rest of
137f90fe02fSChris Kay         * the current memory page is unused.
1388d69a03fSSandrine Bailleux         */
1395629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
140f90fe02fSChris Kay
1418d69a03fSSandrine Bailleux        __COHERENT_RAM_END__ = .;
1428d69a03fSSandrine Bailleux    } >RAM
143f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
1444f6ad66aSAchin Gupta
1458d69a03fSSandrine Bailleux    __BL1_RAM_START__ = ADDR(.data);
1468d69a03fSSandrine Bailleux    __BL1_RAM_END__ = .;
1474f6ad66aSAchin Gupta
1488d69a03fSSandrine Bailleux    __DATA_ROM_START__ = LOADADDR(.data);
1498d69a03fSSandrine Bailleux    __DATA_SIZE__ = SIZEOF(.data);
150c02fcc4aSSandrine Bailleux
151a37255a2SSandrine Bailleux    /*
152a37255a2SSandrine Bailleux     * The .data section is the last PROGBITS section so its end marks the end
153c02fcc4aSSandrine Bailleux     * of BL1's actual content in Trusted ROM.
154a37255a2SSandrine Bailleux     */
155c02fcc4aSSandrine Bailleux    __BL1_ROM_END__ =  __DATA_ROM_START__ + __DATA_SIZE__;
156f90fe02fSChris Kay
157c02fcc4aSSandrine Bailleux    ASSERT(__BL1_ROM_END__ <= BL1_RO_LIMIT,
158c02fcc4aSSandrine Bailleux        "BL1's ROM content has exceeded its limit.")
1598d69a03fSSandrine Bailleux
1608d69a03fSSandrine Bailleux    __BSS_SIZE__ = SIZEOF(.bss);
1618d69a03fSSandrine Bailleux
162ab8707e6SSoby Mathew#if USE_COHERENT_MEM
1638d69a03fSSandrine Bailleux    __COHERENT_RAM_UNALIGNED_SIZE__ =
1648d69a03fSSandrine Bailleux        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
165f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
1668d69a03fSSandrine Bailleux
167a37255a2SSandrine Bailleux    ASSERT(. <= BL1_RW_LIMIT, "BL1's RW section has exceeded its limit.")
1685e7e8bfaSHarrison Mutai    RAM_REGION_END = .;
1694f6ad66aSAchin Gupta}
170