1/*
2 * linker script for LPC1788 (512kB Flash, 48kB + 48kB SRAM ) with GNU ld
3 * yiyue.fang 2012-04-14
4 */
5
6/* Program Entry, set to mark it as "used" and avoid gc */
7MEMORY
8{
9    CODE (rx) : ORIGIN = 0x00000000, LENGTH = 512k  /* 512k flash */
10    DATA (rw) : ORIGIN = 0x10000000, LENGTH = 64k   /* 64k sram */
11}
12ENTRY(Reset_Handler)
13_system_stack_size = 0x200;
14
15SECTIONS
16{
17    .text :
18    {
19        . = ALIGN(4);
20        KEEP(*(.interrupt_vector))      /* Startup code */
21        . = ALIGN(4);
22        *(.text)                        /* remaining code */
23        *(.text.*)                      /* remaining code */
24        *(.rodata)                      /* read-only data (constants) */
25        *(.rodata*)
26        *(.glue_7)
27        *(.glue_7t)
28        *(.gnu.linkonce.t*)
29
30        /* section information for finsh shell */
31        . = ALIGN(4);
32        __fsymtab_start = .;
33        KEEP(*(FSymTab))
34        __fsymtab_end = .;
35        . = ALIGN(4);
36        __vsymtab_start = .;
37        KEEP(*(VSymTab))
38        __vsymtab_end = .;
39        . = ALIGN(4);
40
41        /* section information for initial. */
42        . = ALIGN(4);
43        __rt_init_start = .;
44        KEEP(*(SORT(.rti_fn*)))
45        __rt_init_end = .;
46        . = ALIGN(4);
47
48        PROVIDE(__ctors_start__ = .);
49        /* old GCC version uses .ctors */
50        KEEP(*(SORT(.ctors.*)))
51        KEEP(*(.ctors))
52        /* new GCC version uses .init_array */
53        KEEP (*(SORT(.init_array.*)))
54        KEEP (*(.init_array))
55        PROVIDE(__ctors_end__ = .);
56
57        . = ALIGN(4);
58        _etext = .;
59    } > CODE = 0
60
61    .ARM.extab :
62    {
63        *(.ARM.extab*)
64    } > CODE
65
66    /* The .ARM.exidx section is used for C++ exception handling. */
67    /* .ARM.exidx is sorted, so has to go in its own output section.  */
68    __exidx_start = .;
69    .ARM.exidx :
70    {
71        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
72
73        /* This is used by the startup in order to initialize the .data secion */
74        _sidata = .;
75    } > CODE
76    __exidx_end = .;
77
78    /* .data section which is used for initialized data */
79
80    .data : AT (_sidata)
81    {
82        . = ALIGN(4);
83        PROVIDE(__dtors_start__ = .);
84        KEEP(*(SORT(.dtors.*)))
85        KEEP(*(.dtors))
86        PROVIDE(__dtors_end__ = .);
87
88        . = ALIGN(4);
89        /* This is used by the startup in order to initialize the .data secion */
90        _sdata = . ;
91
92        *(.data)
93        *(.data.*)
94        *(.gnu.linkonce.d*)
95
96        . = ALIGN(4);
97        /* This is used by the startup in order to initialize the .data secion */
98        _edata = . ;
99    } > DATA
100
101    .stack :
102    {
103        . = . + _system_stack_size;
104        . = ALIGN(4);
105        _estack = .;
106    } >DATA
107
108    __bss_start = .;
109    .bss :
110    {
111        . = ALIGN(4);
112        /* This is used by the startup in order to initialize the .bss secion */
113        _sbss = .;
114
115        *(.bss)
116        *(.bss.*)
117        *(COMMON)
118
119        . = ALIGN(4);
120        /* This is used by the startup in order to initialize the .bss secion */
121        _ebss = . ;
122        *(.bss.init)
123    } > DATA
124    __bss_end = .;
125
126    _end = .;
127
128    /* Stabs debugging sections.  */
129    .stab          0 : { *(.stab) }
130    .stabstr       0 : { *(.stabstr) }
131    .stab.excl     0 : { *(.stab.excl) }
132    .stab.exclstr  0 : { *(.stab.exclstr) }
133    .stab.index    0 : { *(.stab.index) }
134    .stab.indexstr 0 : { *(.stab.indexstr) }
135    .comment       0 : { *(.comment) }
136    /* DWARF debug sections.
137     * Symbols in the DWARF debugging sections are relative to the beginning
138     * of the section so we begin them at 0.  */
139    /* DWARF 1 */
140    .debug          0 : { *(.debug) }
141    .line           0 : { *(.line) }
142    /* GNU DWARF 1 extensions */
143    .debug_srcinfo  0 : { *(.debug_srcinfo) }
144    .debug_sfnames  0 : { *(.debug_sfnames) }
145    /* DWARF 1.1 and DWARF 2 */
146    .debug_aranges  0 : { *(.debug_aranges) }
147    .debug_pubnames 0 : { *(.debug_pubnames) }
148    /* DWARF 2 */
149    .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
150    .debug_abbrev   0 : { *(.debug_abbrev) }
151    .debug_line     0 : { *(.debug_line) }
152    .debug_frame    0 : { *(.debug_frame) }
153    .debug_str      0 : { *(.debug_str) }
154    .debug_loc      0 : { *(.debug_loc) }
155    .debug_macinfo  0 : { *(.debug_macinfo) }
156    /* SGI/MIPS DWARF 2 extensions */
157    .debug_weaknames 0 : { *(.debug_weaknames) }
158    .debug_funcnames 0 : { *(.debug_funcnames) }
159    .debug_typenames 0 : { *(.debug_typenames) }
160    .debug_varnames  0 : { *(.debug_varnames) }
161}
162