1/*
2 * Copyright (c) 2022 Arm Limited
3 * Copyright (c) 2021 IAR Systems AB
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19/* Linker script to configure memory regions. */
20/* This file will be run trough the pre-processor. */
21
22#include "region_defs.h"
23
24do not initialize  { section .noinit };
25initialize by copy { readwrite };
26
27define block ER_CODE        with fixed order, alignment = 8 {
28       section .intvec,
29       readonly
30       };
31define block LR_CODE with fixed order, maximum size = BL2_CODE_SIZE {block ER_CODE};
32place at address BL2_CODE_START {block LR_CODE};
33
34define block TFM_SHARED_DATA with alignment = 32, size = BOOT_TFM_SHARED_DATA_SIZE { };
35define block ER_DATA         with alignment = 32 {readwrite};
36#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
37define block ARM_LIB_STACK   with alignment = 32, size = BL2_MSP_STACK_SIZE - 0x8 { };
38define block STACKSEAL with size = 0x8 { };
39#else
40define block ARM_LIB_STACK   with alignment = 32, size = BL2_MSP_STACK_SIZE { };
41#endif /* #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
42define block HEAP            with alignment = 8, size = BL2_HEAP_SIZE { };
43define block ARM_LIB_HEAP    with alignment = 8, size = BL2_HEAP_SIZE { };
44define overlay HEAP_OVL      {block HEAP};
45define overlay HEAP_OVL      {block ARM_LIB_HEAP};
46keep {block TFM_SHARED_DATA, block ER_DATA, block ARM_LIB_STACK,
47      block HEAP, block ARM_LIB_HEAP};
48
49if (isdefinedsymbol(__USE_DLIB_PERTHREAD))
50{
51  // Required in a multi-threaded application
52  initialize by copy with packing = none { section __DLIB_PERTHREAD };
53}
54
55define block DATA with fixed order, maximum size = BL2_DATA_SIZE {
56       block TFM_SHARED_DATA,
57       block ER_DATA,
58       block ARM_LIB_STACK,
59#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
60       block STACKSEAL,
61#endif /* #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
62       overlay HEAP_OVL
63};
64place at address BOOT_TFM_SHARED_DATA_BASE {block DATA};
65