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