aboutsummaryrefslogtreecommitdiff
path: root/linker/linker_script.ld
blob: d472646eae7e488a7803f50d470e9660c20bd9f3 (plain) (blame)
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
MEMORY
{
  flash : org = 0x08000000, len = 256k
  sram1 : org = 0x20000000, len = 48k
  sram2 : org = 0x10000000, len = 16k
}

SECTIONS
{
  /* This is where the code goes. */
  . = ORIGIN(flash);
  .text ALIGN(0x04) : {
    . = ALIGN(0x04);
    VECTORS_START = .;
    *(.vectors); /* All .vector sections go here. */
    VECTORS_END = .;

    *(.got); /* Section to store the linker variables. */

    TEXT_START = .;
    *(.text);    /* All .text sections go here. */
    TEXT_END = .;

    /* Start the init sections. The inits sections are text sections which are
     * executed in order during startup. */
    INITS_START = .;
    INIT_0_START = .;
    *(.init0);
    INIT_0_END = .;
    INIT_1_START = .;
    *(.init1);
    INIT_1_END = .;
    INIT_2_START = .;
    *(.init2);
    INIT_2_END = .;
    INIT_3_START = .;
    *(.init3);
    INIT_3_END = .;
    INIT_4_START = .;
    *(.init4);
    INIT_4_END = .;
    INIT_5_START = .;
    *(.init5);
    INIT_5_END = .;
    INIT_6_START = .;
    *(.init6);
    INIT_6_END = .;
    INIT_7_START = .;
    *(.init7);
    INIT_7_END = .;
    INITS_END = .;

    FLASH_STOP = .;
  } >flash AT >flash

  /* Data segment as defined in the flash. */
  DATA_VALUES_IN_FLASH = LOADADDR(.data);

  .data : ALIGN(0x04) {

    /* Data segment where it will be in memory. */
    . = ALIGN(0x04);
    DATA_SEGMENT_START = .;
    *(.data);
    DATA_SEGMENT_STOP = .;

    /* Align by 4 so we can optimize the copier to use uint32's. */
    . = ALIGN(0x04);

    *(.noinit);

  } >sram2 AT>flash

  .bss : ALIGN(0x04){
    . = ALIGN(0x04);
    BSS_START = .;
    *(.bss);
    . = ALIGN(0x04);
    BSS_END = .;
  } > sram2

  .heap : ALIGN(0x04) {
    HEAP_START = .;
    HEAP_STOP = ABSOLUTE(ORIGIN(sram1) + LENGTH(sram1));
  } > sram1
}