summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/board/compal_e88/loader.lds
blob: a7a001fc503bafe6bc782fa5bd58af9689e48a47 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 * Linker script for flashed loader on the Compal E88
 *
 * This script creates a binary that can replace a standard firmware
 * located at 0x2000. It works in conjunction with the compal ramloader.
 *
 * The interrupt vectors and start address are at known, fixed offsets.
 *
 */
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
MEMORY
{
    /* 2 MBytes of external flash memory */
    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x200000
    /* 256 kBytes of internal zero-waitstate sram */
    IRAM  (rw) : ORIGIN = 0x00800000, LENGTH = 0x040000
    /* 256 kBytes of external slow sram */
    ERAM  (rw) : ORIGIN = 0x01000000, LENGTH = 0x040000
}
SECTIONS
{
    /* Provide symbols for the compal loader */
    .compal.loader 0x00000000 (NOLOAD) : {
        _compal_loader_start = .;
        . = 0x2000;
        _compal_loader_end = .;
    } > FLASH

    /* Compal-style image header */
    .compal.header 0x00002000 : {
        _compal_header_start = .;
        KEEP(*(.compal.header))
        *(.compal.header)
        . = 0xA0;
        _compal_header_end = .;
    } > FLASH

    /* Compal-style vector table */
    .compal.vectors 0x000020A0 : {
        PROVIDE(_exceptions = .);
        KEEP(*(.text.exceptions))
        *(.text.exceptions)
    } > FLASH

    /* Compal-style entry point */
    .text.start 0x000020F8 : {
        PROVIDE(_start = .);
        KEEP(*(.text.start))
        *(.text.start)
    } > FLASH

    /* code */
    .text : {
        /* regular code */
        *(.text*)
        /* gcc voodoo */
        *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
    } > FLASH
    PROVIDE(_text_start = ADDR(.text));
    PROVIDE(_text_end = ADDR(.text) + SIZEOF(.text));

    /* constructor pointers */
    .ctors : {
        /* ctor count */
        LONG(SIZEOF(.ctors) / 4 - 2)
        /* ctor pointers */
        KEEP(*(SORT(.ctors)))
        /* end of list */
        LONG(0)
    } > FLASH
    PROVIDE(_ctor_start = LOADADDR(.ctors));
    PROVIDE(_ctor_end = LOADADDR(.ctors) + SIZEOF(.ctors));

    /* destructor pointers */
    .dtors : {
        /* dtor count */
        LONG(SIZEOF(.dtors) / 4 - 2)
        /* dtor pointers */
        KEEP(*(SORT(.dtors)))
        /* end of list */
        LONG(0)
    } > FLASH
    PROVIDE(_dtor_start = LOADADDR(.dtors));
    PROVIDE(_dtor_end = LOADADDR(.dtors) + SIZEOF(.dtors));

    /* read-only data */
    .rodata : {
        *(.rodata*)
    } > FLASH
    PROVIDE(_rodata_start = ADDR(.rodata));
    PROVIDE(_rodata_end = ADDR(.rodata) + SIZEOF(.rodata));

    /* pic offset tables */
    .got : {
        . = ALIGN(4);
        *(.got)
        *(.got.plt) *(.igot.plt) *(.got) *(.igot)
        . = ALIGN(4);
    } > FLASH
    PROVIDE(_got_start = ADDR(.got));
    PROVIDE(_got_end = ADDR(.got) + SIZEOF(.got));

    /* reserved ram  */
    .compal.reservedram 0x800000 (NOLOAD) : {
        . = 0xff;
    } > IRAM

    /* initialized data */
    .data : AT (LOADADDR(.got) + SIZEOF(.got)) {
        . = ALIGN(4);
        *(.data)
        . = ALIGN(4);
    } > IRAM
    PROVIDE(__data_start = LOADADDR(.data));
    PROVIDE(__data_end = LOADADDR(.data) + SIZEOF(.data));
    PROVIDE(_data_start = ADDR(.data));
    PROVIDE(_data_end = ADDR(.data) + SIZEOF(.data));

    /* ram code */
    .ramtext : AT (LOADADDR(.data) + SIZEOF(.data)) {
        . = ALIGN(4);
        *(.ramtext)
        . = ALIGN(4);
    } > IRAM
    PROVIDE(__ramtext_start = LOADADDR(.ramtext));
    PROVIDE(__ramtext_end = LOADADDR(.ramtext) + SIZEOF(.ramtext));
    PROVIDE(_ramtext_start = ADDR(.ramtext));
    PROVIDE(_ramtext_end = ADDR(.ramtext) + SIZEOF(.ramtext));

    /* uninitialized data */
    .bss (NOLOAD) : {
        . = ALIGN(4);
        *(.bss)
        . = ALIGN(4);
    } > IRAM
    PROVIDE(__bss_start = ADDR(.bss));
    PROVIDE(__bss_end = ADDR(.bss) + SIZEOF(.bss));
    PROVIDE(_bss_start = __bss_start);
    PROVIDE(_bss_end = __bss_end);

    /* end of image */
    . = ALIGN(4);
    _end = .;
    PROVIDE(end = .);
}