xref: /rk3399_ARM-atf/bl32/sp_min/sp_min.ld.S (revision 7303319b3823e9e33748d963e9173f3678aba4da)
1c11ba852SSoby Mathew/*
2*7256cf0aSRohit Mathew * Copyright (c) 2016-2025, 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>
8*7256cf0aSRohit Mathew#include <lib/per_cpu/per_cpu_defs.h>
909d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
10c11ba852SSoby Mathew
11c11ba852SSoby MathewOUTPUT_FORMAT(elf32-littlearm)
12c11ba852SSoby MathewOUTPUT_ARCH(arm)
13c11ba852SSoby MathewENTRY(sp_min_vector_table)
14c11ba852SSoby Mathew
15c11ba852SSoby MathewMEMORY {
16c11ba852SSoby Mathew    RAM (rwx): ORIGIN = BL32_BASE, LENGTH = BL32_LIMIT - BL32_BASE
17c11ba852SSoby Mathew}
18c11ba852SSoby Mathew
1914e09cc4SHeiko Stuebner#ifdef PLAT_SP_MIN_EXTRA_LD_SCRIPT
2014e09cc4SHeiko Stuebner#   include <plat_sp_min.ld.S>
21f90fe02fSChris Kay#endif /* PLAT_SP_MIN_EXTRA_LD_SCRIPT */
22c11ba852SSoby Mathew
23f90fe02fSChris KaySECTIONS {
24fcb72e16SHarrison Mutai    RAM_REGION_START = ORIGIN(RAM);
25fcb72e16SHarrison Mutai    RAM_REGION_LENGTH = LENGTH(RAM);
26c11ba852SSoby Mathew    . = BL32_BASE;
27f90fe02fSChris Kay
28a2aedac2SAntonio Nino Diaz    ASSERT(. == ALIGN(PAGE_SIZE),
29c11ba852SSoby Mathew        "BL32_BASE address is not aligned on a page boundary.")
30c11ba852SSoby Mathew
31c11ba852SSoby Mathew#if SEPARATE_CODE_AND_RODATA
32c11ba852SSoby Mathew    .text . : {
333d6edc32SAndrey Skvortsov        ASSERT(. == ALIGN(PAGE_SIZE),
343d6edc32SAndrey Skvortsov        ".text address is not aligned on a page boundary.");
353d6edc32SAndrey Skvortsov
36c11ba852SSoby Mathew        __TEXT_START__ = .;
37f90fe02fSChris Kay
38c11ba852SSoby Mathew        *entrypoint.o(.text*)
39b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.text*))
403bdf0e5dSYatharth Kochar        *(.vectors)
41f7d445fcSMichal Simek        __TEXT_END_UNALIGNED__ = .;
42f90fe02fSChris Kay
435629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
44f90fe02fSChris Kay
45c11ba852SSoby Mathew        __TEXT_END__ = .;
46c11ba852SSoby Mathew    } >RAM
47c11ba852SSoby Mathew
48f90fe02fSChris Kay    /* .ARM.extab and .ARM.exidx are only added because Clang needs them */
49ad925094SRoberto Vargas    .ARM.extab . : {
50ad925094SRoberto Vargas        *(.ARM.extab* .gnu.linkonce.armextab.*)
51ad925094SRoberto Vargas    } >RAM
52ad925094SRoberto Vargas
53ad925094SRoberto Vargas    .ARM.exidx . : {
54ad925094SRoberto Vargas        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
55ad925094SRoberto Vargas    } >RAM
56ad925094SRoberto Vargas
57c11ba852SSoby Mathew    .rodata . : {
58c11ba852SSoby Mathew        __RODATA_START__ = .;
59b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.rodata*))
60c11ba852SSoby Mathew
610a0a7a9aSMasahiro Yamada        RODATA_COMMON
62c11ba852SSoby Mathew
638e743bcdSJeenu Viswambharan        . = ALIGN(8);
64f90fe02fSChris Kay
6509d40e0eSAntonio Nino Diaz#   include <lib/el3_runtime/pubsub_events.h>
66f7d445fcSMichal Simek        __RODATA_END_UNALIGNED__ = .;
678e743bcdSJeenu Viswambharan
685629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
69f90fe02fSChris Kay
70c11ba852SSoby Mathew        __RODATA_END__ = .;
71c11ba852SSoby Mathew    } >RAM
72f90fe02fSChris Kay#else /* SEPARATE_CODE_AND_RODATA */
73da04341eSChris Kay    .ro . : {
743d6edc32SAndrey Skvortsov        ASSERT(. == ALIGN(PAGE_SIZE),
753d6edc32SAndrey Skvortsov        ".ro address is not aligned on a page boundary.");
763d6edc32SAndrey Skvortsov
77c11ba852SSoby Mathew        __RO_START__ = .;
78f90fe02fSChris Kay
79c11ba852SSoby Mathew        *entrypoint.o(.text*)
80b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.text*))
81b1f596b6SYann Gautier        *(SORT_BY_ALIGNMENT(.rodata*))
82c11ba852SSoby Mathew
830a0a7a9aSMasahiro Yamada        RODATA_COMMON
84c11ba852SSoby Mathew
858e743bcdSJeenu Viswambharan        . = ALIGN(8);
86f90fe02fSChris Kay
8709d40e0eSAntonio Nino Diaz#   include <lib/el3_runtime/pubsub_events.h>
888e743bcdSJeenu Viswambharan
893bdf0e5dSYatharth Kochar        *(.vectors)
90f90fe02fSChris Kay
91c11ba852SSoby Mathew        __RO_END_UNALIGNED__ = .;
92c11ba852SSoby Mathew
93c11ba852SSoby Mathew        /*
94f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as device
95f90fe02fSChris Kay         * memory. No other unexpected data must creep in. Ensure that the rest
96f90fe02fSChris Kay         * of the current memory page is unused.
97c11ba852SSoby Mathew         */
985629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
99f90fe02fSChris Kay
100c11ba852SSoby Mathew        __RO_END__ = .;
101c11ba852SSoby Mathew    } >RAM
102f90fe02fSChris Kay#endif /* SEPARATE_CODE_AND_RODATA */
103c11ba852SSoby Mathew
104c11ba852SSoby Mathew    ASSERT(__CPU_OPS_END__ > __CPU_OPS_START__,
105c11ba852SSoby Mathew        "cpu_ops not defined for this platform.")
106f90fe02fSChris Kay
107c11ba852SSoby Mathew    __RW_START__ = .;
108c11ba852SSoby Mathew
109caa3e7e0SMasahiro Yamada    DATA_SECTION >RAM
1104324a14bSYann Gautier    RELA_SECTION >RAM
111c11ba852SSoby Mathew
1125744e874SSoby Mathew#ifdef BL32_PROGBITS_LIMIT
1135744e874SSoby Mathew    ASSERT(. <= BL32_PROGBITS_LIMIT, "BL32 progbits has exceeded its limit.")
114f90fe02fSChris Kay#endif /* BL32_PROGBITS_LIMIT */
1155744e874SSoby Mathew
116a926a9f6SMasahiro Yamada    STACK_SECTION >RAM
117a7739bc7SMasahiro Yamada    BSS_SECTION >RAM
118*7256cf0aSRohit Mathew    PER_CPU >RAM
119665e71b8SMasahiro Yamada    XLAT_TABLE_SECTION >RAM
120c11ba852SSoby Mathew
121c11ba852SSoby Mathew    __BSS_SIZE__ = SIZEOF(.bss);
122c11ba852SSoby Mathew
123c11ba852SSoby Mathew#if USE_COHERENT_MEM
124c11ba852SSoby Mathew    /*
125f90fe02fSChris Kay     * The base address of the coherent memory section must be page-aligned to
126f90fe02fSChris Kay     * guarantee that the coherent data are stored on their own pages and are
127f90fe02fSChris Kay     * not mixed with normal data.  This is required to set up the correct
128c11ba852SSoby Mathew     * memory attributes for the coherent data page tables.
129c11ba852SSoby Mathew     */
130da04341eSChris Kay    .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
131c11ba852SSoby Mathew        __COHERENT_RAM_START__ = .;
132f90fe02fSChris Kay
133c11ba852SSoby Mathew        /*
134f90fe02fSChris Kay         * Bakery locks are stored in coherent memory. Each lock's data is
135f90fe02fSChris Kay         * contiguous and fully allocated by the compiler.
136c11ba852SSoby Mathew         */
137da04341eSChris Kay        *(.bakery_lock)
138da04341eSChris Kay        *(.tzfw_coherent_mem)
139f90fe02fSChris Kay
140c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ = .;
141f90fe02fSChris Kay
142c11ba852SSoby Mathew        /*
143f90fe02fSChris Kay         * Memory page(s) mapped to this section will be marked as device
144f90fe02fSChris Kay         * memory. No other unexpected data must creep in. Ensure that the rest
145f90fe02fSChris Kay         * of the current memory page is unused.
146c11ba852SSoby Mathew         */
1475629b2b1SRoberto Vargas        . = ALIGN(PAGE_SIZE);
148f90fe02fSChris Kay
149c11ba852SSoby Mathew        __COHERENT_RAM_END__ = .;
150c11ba852SSoby Mathew    } >RAM
151c11ba852SSoby Mathew
152c11ba852SSoby Mathew    __COHERENT_RAM_UNALIGNED_SIZE__ =
153c11ba852SSoby Mathew        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
154f90fe02fSChris Kay#endif /* USE_COHERENT_MEM */
155c11ba852SSoby Mathew
156c11ba852SSoby Mathew    __RW_END__ = .;
157c11ba852SSoby Mathew    __BL32_END__ = .;
158fdd97d7cSYann Gautier
1594324a14bSYann Gautier    /DISCARD/ : {
1604324a14bSYann Gautier        *(.dynsym .dynstr .hash .gnu.hash)
1614324a14bSYann Gautier    }
1624324a14bSYann Gautier
163fdd97d7cSYann Gautier    ASSERT(. <= BL32_LIMIT, "BL32 image has exceeded its limit.")
164fcb72e16SHarrison Mutai    RAM_REGION_END = .;
165c11ba852SSoby Mathew}
166