summaryrefslogtreecommitdiff
path: root/realm/realm.ld.S
blob: ca3b809b37a7d1c9187d0c3e1d4576b643259962 (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
/*
 * Copyright (c) 2022, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */


ENTRY(realm_entrypoint)

#include <realm_def.h>

MEMORY {

    RAM (rwx): ORIGIN = 0x0, LENGTH = REALM_MAX_LOAD_IMG_SIZE
}

SECTIONS
{
     ASSERT(. == ALIGN(PAGE_SIZE),
           "TEXT_START address is not aligned to PAGE_SIZE.")
    .text : {
        __REALM_TEXT_START__ = .;
        *realm_entrypoint.o(.text*)
        *(.text*)
        *(.vectors)
        . = NEXT(PAGE_SIZE);
        __REALM_TEXT_END__ = .;
    }> RAM

    .rodata : {
        . = ALIGN(PAGE_SIZE);
        __REALM_RODATA_START__ = .;
        *(.rodata*)

        /*
         * Keep the .got section in the RO section as it is patched
         * prior to enabling the MMU and having the .got in RO is better for
         * security. GOT is a table of addresses so ensure 8-byte alignment.
         */
        . = ALIGN(8);
        __GOT_START__ = .;
        *(.got)
        __GOT_END__ = .;

        . = NEXT(PAGE_SIZE);
        __REALM_RODATA_END__ = .;

    }> RAM

    .data : {
        . = ALIGN(PAGE_SIZE);
        __REALM_DATA_START__ = .;
        *(.data*)
        . = ALIGN(PAGE_SIZE);
        . = NEXT(PAGE_SIZE);
        __REALM_DATA_END__ = .;
    }> RAM

    /*
     * .rela.dyn needs to come after .data for the read-elf utility to parse
     * this section correctly. Ensure 8-byte alignment so that the fields of
     * RELA data structure are aligned.
     */
    . = ALIGN(8);
    __RELA_START__ = .;
    .rela.dyn . : {
    }> RAM
    __RELA_END__ = .;

    .bss (NOLOAD) : {
        . = ALIGN(PAGE_SIZE);
        __REALM_BSS_START__ = .;
        *(SORT_BY_ALIGNMENT(.bss*))
        *(COMMON)
        . = NEXT(PAGE_SIZE);
        __REALM_BSS_END__ = .;
    }> RAM
    __REALM_BSS_SIZE__ = SIZEOF(.bss);
}