aboutsummaryrefslogtreecommitdiff
path: root/fwu/ns_bl1u/ns_bl1u.ld.S
blob: 2ca5292c5478d5b5c63af326839cb3654e23f2c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Copyright (c) 2018, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <platform_def.h>
#include <xlat_tables_defs.h>

OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
ENTRY(ns_bl1u_entrypoint)

MEMORY {
    ROM (rx): ORIGIN = NS_BL1U_RO_BASE, LENGTH = NS_BL1U_RO_LIMIT - NS_BL1U_RO_BASE
    RAM (rwx): ORIGIN = NS_BL1U_RW_BASE, LENGTH = NS_BL1U_RW_LIMIT - NS_BL1U_RW_BASE
}

SECTIONS
{
    . = NS_BL1U_RO_BASE;
    ASSERT(. == ALIGN(PAGE_SIZE),
           "NS_BL1U_RO_BASE address is not aligned on a page boundary.")

    ro . : {
        __RO_START__ = .;
        *ns_bl1u_entrypoint.o(.text*)
        *(.text*)
        *(.rodata*)
        __RO_END__ = .;
    } >ROM

    /*
     * The .data section gets copied from ROM to RAM at runtime.
     * Its LMA must be 16-byte aligned.
     * Its VMA must be page-aligned as it marks the first read/write page.
     */
    . = NS_BL1U_RW_BASE;
    ASSERT(. == ALIGN(PAGE_SIZE),
           "NS_BL1U_RW_BASE address is not aligned on a page boundary.")
    .data . : ALIGN(16) {
        __DATA_RAM_START__ = .;
        *(.data*)
        __DATA_RAM_END__ = .;
    } >RAM AT>ROM

    stacks . (NOLOAD) : {
        __STACKS_START__ = .;
        *(ns_bl_normal_stacks)
        __STACKS_END__ = .;
    } >RAM

    /*
     * The .bss section gets initialised to 0 at runtime.
     * Its base address must be 16-byte aligned.
     */
    .bss : ALIGN(16) {
        __BSS_START__ = .;
        *(SORT_BY_ALIGNMENT(.bss*))
        *(COMMON)
        __BSS_END__ = .;
    } >RAM

    /*
     * The xlat_table section is for full, aligned page tables (4K).
     * Removing them from .bss avoids forcing 4K alignment on
     * the .bss section and eliminates the unecessary zero init
     */
    xlat_table (NOLOAD) : {
        *(xlat_table)
    } >RAM

    __NS_BL1U_RAM_START__ = ADDR(.data);
    __NS_BL1U_RAM_END__ = .;

    __DATA_ROM_START__ = LOADADDR(.data);
    __DATA_SIZE__ = SIZEOF(.data);

    /*
     * The .data section is the last PROGBITS section so its end marks the end
     * of the read-only part of NS_BL1U's binary.
     */
    ASSERT(__DATA_ROM_START__ + __DATA_SIZE__ <= NS_BL1U_RO_LIMIT,
           "NS_BL1U's RO section has exceeded its limit.")

    __BSS_SIZE__ = SIZEOF(.bss);

    ASSERT(. <= NS_BL1U_RW_LIMIT, "NS_BL1U's RW section has exceeded its limit.")
}