xref: /arm-trusted-firmware/bl32/tsp/tsp.ld.S (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu/*
2*91f16700Schasinglulu * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved.
3*91f16700Schasinglulu *
4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu */
6*91f16700Schasinglulu
7*91f16700Schasinglulu#include <common/bl_common.ld.h>
8*91f16700Schasinglulu#include <lib/xlat_tables/xlat_tables_defs.h>
9*91f16700Schasinglulu
10*91f16700SchasingluluOUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
11*91f16700SchasingluluOUTPUT_ARCH(PLATFORM_LINKER_ARCH)
12*91f16700SchasingluluENTRY(tsp_entrypoint)
13*91f16700Schasinglulu
14*91f16700SchasingluluMEMORY {
15*91f16700Schasinglulu    RAM (rwx): ORIGIN = TSP_SEC_MEM_BASE, LENGTH = TSP_SEC_MEM_SIZE
16*91f16700Schasinglulu}
17*91f16700Schasinglulu
18*91f16700SchasingluluSECTIONS {
19*91f16700Schasinglulu    RAM_REGION_START = ORIGIN(RAM);
20*91f16700Schasinglulu    RAM_REGION_LENGTH = LENGTH(RAM);
21*91f16700Schasinglulu    . = BL32_BASE;
22*91f16700Schasinglulu
23*91f16700Schasinglulu    ASSERT(. == ALIGN(PAGE_SIZE),
24*91f16700Schasinglulu        "BL32_BASE address is not aligned on a page boundary.")
25*91f16700Schasinglulu
26*91f16700Schasinglulu#if SEPARATE_CODE_AND_RODATA
27*91f16700Schasinglulu    .text . : {
28*91f16700Schasinglulu        __TEXT_START__ = .;
29*91f16700Schasinglulu
30*91f16700Schasinglulu        *tsp_entrypoint.o(.text*)
31*91f16700Schasinglulu        *(.text*)
32*91f16700Schasinglulu        *(.vectors)
33*91f16700Schasinglulu        __TEXT_END_UNALIGNED__ = .;
34*91f16700Schasinglulu
35*91f16700Schasinglulu        . = ALIGN(PAGE_SIZE);
36*91f16700Schasinglulu
37*91f16700Schasinglulu        __TEXT_END__ = .;
38*91f16700Schasinglulu    } >RAM
39*91f16700Schasinglulu
40*91f16700Schasinglulu    .rodata . : {
41*91f16700Schasinglulu        __RODATA_START__ = .;
42*91f16700Schasinglulu
43*91f16700Schasinglulu        *(.rodata*)
44*91f16700Schasinglulu
45*91f16700Schasinglulu        RODATA_COMMON
46*91f16700Schasinglulu
47*91f16700Schasinglulu        __RODATA_END_UNALIGNED__ = .;
48*91f16700Schasinglulu        . = ALIGN(PAGE_SIZE);
49*91f16700Schasinglulu
50*91f16700Schasinglulu        __RODATA_END__ = .;
51*91f16700Schasinglulu    } >RAM
52*91f16700Schasinglulu#else /* SEPARATE_CODE_AND_RODATA */
53*91f16700Schasinglulu    .ro . : {
54*91f16700Schasinglulu        __RO_START__ = .;
55*91f16700Schasinglulu
56*91f16700Schasinglulu        *tsp_entrypoint.o(.text*)
57*91f16700Schasinglulu        *(.text*)
58*91f16700Schasinglulu        *(.rodata*)
59*91f16700Schasinglulu
60*91f16700Schasinglulu        RODATA_COMMON
61*91f16700Schasinglulu
62*91f16700Schasinglulu        *(.vectors)
63*91f16700Schasinglulu
64*91f16700Schasinglulu        __RO_END_UNALIGNED__ = .;
65*91f16700Schasinglulu
66*91f16700Schasinglulu        /*
67*91f16700Schasinglulu         * Memory page(s) mapped to this section will be marked as read-only,
68*91f16700Schasinglulu         * executable. No RW data from the next section must creep in. Ensure
69*91f16700Schasinglulu         * that the rest of the current memory page is unused.
70*91f16700Schasinglulu         */
71*91f16700Schasinglulu        . = ALIGN(PAGE_SIZE);
72*91f16700Schasinglulu
73*91f16700Schasinglulu        __RO_END__ = .;
74*91f16700Schasinglulu    } >RAM
75*91f16700Schasinglulu#endif /* SEPARATE_CODE_AND_RODATA */
76*91f16700Schasinglulu
77*91f16700Schasinglulu    __RW_START__ = .;
78*91f16700Schasinglulu
79*91f16700Schasinglulu    DATA_SECTION >RAM
80*91f16700Schasinglulu    RELA_SECTION >RAM
81*91f16700Schasinglulu
82*91f16700Schasinglulu#ifdef TSP_PROGBITS_LIMIT
83*91f16700Schasinglulu    ASSERT(. <= TSP_PROGBITS_LIMIT, "TSP progbits has exceeded its limit.")
84*91f16700Schasinglulu#endif /* TSP_PROGBITS_LIMIT */
85*91f16700Schasinglulu
86*91f16700Schasinglulu    STACK_SECTION >RAM
87*91f16700Schasinglulu    BSS_SECTION >RAM
88*91f16700Schasinglulu    XLAT_TABLE_SECTION >RAM
89*91f16700Schasinglulu
90*91f16700Schasinglulu#if USE_COHERENT_MEM
91*91f16700Schasinglulu    /*
92*91f16700Schasinglulu     * The base address of the coherent memory section must be page-aligned to
93*91f16700Schasinglulu     * guarantee that the coherent data are stored on their own pages and are
94*91f16700Schasinglulu     * not mixed with normal data. This is required to set up the correct memory
95*91f16700Schasinglulu     * attributes for the coherent data page tables.
96*91f16700Schasinglulu     */
97*91f16700Schasinglulu    .coherent_ram (NOLOAD) : ALIGN(PAGE_SIZE) {
98*91f16700Schasinglulu        __COHERENT_RAM_START__ = .;
99*91f16700Schasinglulu        *(.tzfw_coherent_mem)
100*91f16700Schasinglulu        __COHERENT_RAM_END_UNALIGNED__ = .;
101*91f16700Schasinglulu
102*91f16700Schasinglulu        /*
103*91f16700Schasinglulu         * Memory page(s) mapped to this section will be marked as device
104*91f16700Schasinglulu         * memory. No other unexpected data must creep in. Ensure that the rest
105*91f16700Schasinglulu         * of the current memory page is unused.
106*91f16700Schasinglulu         */
107*91f16700Schasinglulu        . = ALIGN(PAGE_SIZE);
108*91f16700Schasinglulu
109*91f16700Schasinglulu        __COHERENT_RAM_END__ = .;
110*91f16700Schasinglulu    } >RAM
111*91f16700Schasinglulu#endif /* USE_COHERENT_MEM */
112*91f16700Schasinglulu
113*91f16700Schasinglulu    __RW_END__ = .;
114*91f16700Schasinglulu    __BL32_END__ = .;
115*91f16700Schasinglulu
116*91f16700Schasinglulu    /DISCARD/ : {
117*91f16700Schasinglulu        *(.dynsym .dynstr .hash .gnu.hash)
118*91f16700Schasinglulu    }
119*91f16700Schasinglulu
120*91f16700Schasinglulu    __BSS_SIZE__ = SIZEOF(.bss);
121*91f16700Schasinglulu
122*91f16700Schasinglulu#if USE_COHERENT_MEM
123*91f16700Schasinglulu    __COHERENT_RAM_UNALIGNED_SIZE__ =
124*91f16700Schasinglulu        __COHERENT_RAM_END_UNALIGNED__ - __COHERENT_RAM_START__;
125*91f16700Schasinglulu#endif /* USE_COHERENT_MEM */
126*91f16700Schasinglulu
127*91f16700Schasinglulu    ASSERT(. <= BL32_LIMIT, "BL32 image has exceeded its limit.")
128*91f16700Schasinglulu    RAM_REGION_END = .;
129*91f16700Schasinglulu}
130