xref: /rk3399_ARM-atf/bl32/sp_min/sp_min.ld.S (revision f7d445fcbbd3d5146d95698ace3381fcf522b9af)
1c11ba852SSoby Mathew/*
2da04341eSChris Kay * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
3c11ba852SSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5c11ba852SSoby Mathew */
6c11ba852SSoby Mathew
7665e71b8SMasahiro Yamada#include <common/bl_common.ld.h>
809d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
9c11ba852SSoby Mathew
10c11ba852SSoby MathewOUTPUT_FORMAT(elf32-littlearm)
11c11ba852SSoby MathewOUTPUT_ARCH(arm)
12c11ba852SSoby MathewENTRY(sp_min_vector_table)
13c11ba852SSoby Mathew
14c11ba852SSoby MathewMEMORY {
15c11ba852SSoby Mathew    RAM (rwx): ORIGIN = BL32_BASE, LENGTH = BL32_LIMIT - BL32_BASE
16c11ba852SSoby Mathew}
17c11ba852SSoby Mathew
1814e09cc4SHeiko Stuebner#ifdef PLAT_SP_MIN_EXTRA_LD_SCRIPT
1914e09cc4SHeiko Stuebner#   include <plat_sp_min.ld.S>
20f90fe02fSChris Kay#endif /* PLAT_SP_MIN_EXTRA_LD_SCRIPT */
21c11ba852SSoby Mathew
22f90fe02fSChris KaySECTIONS {
23fcb72e16SHarrison Mutai    RAM_REGION_START = ORIGIN(RAM);
24fcb72e16SHarrison Mutai    RAM_REGION_LENGTH = LENGTH(RAM);
25c11ba852SSoby Mathew    . = BL32_BASE;
26f90fe02fSChris Kay
27a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
28c11ba852SSoby Mathew        "BL32_BASE address is not aligned on a page boundary.")
29c11ba852SSoby Mathew
30c11ba852SSoby Mathew#if SEPARATE_CODE_AND_RODATA
31c11ba852SSoby Mathew    .text . : {
32c11ba852SSoby Mathew        __TEXT_START__ = .;
33f90fe02fSChris Kay
34c11ba852SSoby Mathew        *entrypoint.o(.text*)
35b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.text*))
363bdf0e5dSYatharth Kochar        *(.vectors)
37*f7d445fcSMichal Simek        __TEXT_END_UNALIGNED__ = .;
38f90fe02fSChris Kay
395629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
40f90fe02fSChris Kay
41c11ba852SSoby Mathew        __TEXT_END__ = .;
42c11ba852SSoby Mathew    } >RAM
43c11ba852SSoby Mathew
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
53c11ba852SSoby Mathew    .rodata . : {
54c11ba852SSoby Mathew        __RODATA_START__ = .;
55b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.rodata*))
56c11ba852SSoby Mathew
570a0a7a9aSMasahiro Yamada        RODATA_COMMON
58c11ba852SSoby Mathew
598e743bcdSJeenu Viswambharan        . = ALIGN(8);
60f90fe02fSChris Kay
6109d40e0eSAntonio Nino Diaz#   include <lib/el3_runtime/pubsub_events.h>
62*f7d445fcSMichal Simek        __RODATA_END_UNALIGNED__ = .;
638e743bcdSJeenu Viswambharan
645629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
65f90fe02fSChris Kay
66c11ba852SSoby Mathew        __RODATA_END__ = .;
67c11ba852SSoby Mathew    } >RAM
68f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */
69da04341eSChris Kay    .ro . : {
70c11ba852SSoby Mathew        __RO_START__ = .;
71f90fe02fSChris Kay
72c11ba852SSoby Mathew        *entrypoint.o(.text*)
73b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.text*))
74b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.rodata*))
75c11ba852SSoby Mathew
760a0a7a9aSMasahiro Yamada        RODATA_COMMON
77c11ba852SSoby Mathew
788e743bcdSJeenu Viswambharan        . = ALIGN(8);
79f90fe02fSChris Kay
8009d40e0eSAntonio Nino Diaz#   include <lib/el3_runtime/pubsub_events.h>
818e743bcdSJeenu Viswambharan
823bdf0e5dSYatharth Kochar        *(.vectors)
83f90fe02fSChris Kay
84c11ba852SSoby Mathew        __RO_END_UNALIGNED__ = .;
85c11ba852SSoby Mathew
86c11ba852SSoby Mathew        /*
87f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as device
88f90fe02fSChris Kay         * memory. No other unexpected data must creep in. Ensure that the rest
89f90fe02fSChris Kay         * of the current memory page is unused.
90c11ba852SSoby Mathew         */
915629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
92f90fe02fSChris Kay
93c11ba852SSoby Mathew        __RO_END__ = .;
94c11ba852SSoby Mathew    } >RAM
95f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */
96c11ba852SSoby Mathew
97c11ba852SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
98c11ba852SSoby Mathew        "cpu_ops not defined for this platform.")
99f90fe02fSChris Kay
100c11ba852SSoby Mathew    __RW_START__ = .;
101c11ba852SSoby Mathew
102caa3e7e0SMasahiro Yamada    DATA_SECTION >RAM
1034324a14bSYann Gautier    RELA_SECTION >RAM
104c11ba852SSoby Mathew
1055744e874SSoby Mathew#ifdef BL32_PROGBITS_LIMIT
1065744e874SSoby Mathew    ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.")
107f90fe02fSChris Kay#endif /* BL32_PROGBITS_LIMIT */
1085744e874SSoby Mathew
109a926a9f6SMasahiro Yamada    STACK_SECTION >RAM
110a7739bc7SMasahiro Yamada    BSS_SECTION >RAM
111665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
112c11ba852SSoby Mathew
113c11ba852SSoby Mathew    __BSS_SIZE__ = SIZEOF(.bss);
114c11ba852SSoby Mathew
115c11ba852SSoby Mathew#if USE_COHERENT_MEM
116c11ba852SSoby Mathew    /*
117f90fe02fSChris Kay     * The base address of the coherent memory section must be page-aligned to
118f90fe02fSChris Kay     * guarantee that the coherent data are stored on their own pages and are
119f90fe02fSChris Kay     * not mixed with normal data.  This is required to set up the correct
120c11ba852SSoby Mathew     * memory attributes for the coherent data page tables.
121c11ba852SSoby Mathew     */
122da04341eSChris Kay    .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
123c11ba852SSoby Mathew        __COHERENT_RAM_START__ = .;
124f90fe02fSChris Kay
125c11ba852SSoby Mathew        /*
126f90fe02fSChris Kay         * Bakery locks are stored in coherent memory. Each lock's data is
127f90fe02fSChris Kay         * contiguous and fully allocated by the compiler.
128c11ba852SSoby Mathew         */
129da04341eSChris Kay        *(.bakery_lock)
130da04341eSChris Kay        *(.tzfw_coherent_mem)
131f90fe02fSChris Kay
132c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ = .;
133f90fe02fSChris Kay
134c11ba852SSoby Mathew        /*
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 that the rest
137f90fe02fSChris Kay         * of the current memory page is unused.
138c11ba852SSoby Mathew         */
1395629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
140f90fe02fSChris Kay
141c11ba852SSoby Mathew        __COHERENT_RAM_END__ = .;
142c11ba852SSoby Mathew    } >RAM
143c11ba852SSoby Mathew
144c11ba852SSoby Mathew    __COHERENT_RAM_UNALIGNED_SIZE__ =
145c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
146f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
147c11ba852SSoby Mathew
148c11ba852SSoby Mathew    __RW_END__ = .;
149c11ba852SSoby Mathew    __BL32_END__ = .;
150fdd97d7cSYann Gautier
1514324a14bSYann Gautier    /DISCARD/ : {
1524324a14bSYann Gautier        *(.dynsym .dynstr .hash .gnu.hash)
1534324a14bSYann Gautier    }
1544324a14bSYann Gautier
155fdd97d7cSYann Gautier    ASSERT(. <= BL32_LIMIT, "BL32 image has exceeded its limit.")
156fcb72e16SHarrison Mutai    RAM_REGION_END = .;
157c11ba852SSoby Mathew}
158