Refactor and reorder ld script for cortex-m3.
[bertos.git] / bertos / cpu / cortex-m3 / scripts / cortex-m3_rom.ld
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \brief Script Cortex M3 family processors.
34  *
35  * \author Daniele Basile <asterix@develer.com>
36  */
37
38 OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
39 OUTPUT_ARCH(arm)
40
41 /*
42  * Define stack size here
43  */
44 STACK_SIZE = 0x1000;
45
46 /*
47  * Allocate section memory
48  */
49 SECTIONS
50 {
51         .text :
52         {
53                 KEEP(*(.vectors));
54                 . = ALIGN (4);
55                 KEEP(*(.init));
56                 . = ALIGN (4);
57                 *(.rodata .rodata.*);
58                 . = ALIGN (4);
59                 *(.text .text.*);
60                 . = ALIGN (4);
61                 *(.glue_7t);
62                 . = ALIGN(4);
63                 *(.glue_7);
64                 . = ALIGN(4);
65         } > rom
66
67         __text_end = .;
68         PROVIDE (__text_end = .);
69
70         .data : AT (__text_end)
71         {
72                 . = ALIGN (0x400);
73                 PROVIDE (__data_start = .);
74                 *(vtable)
75                 *(.data .data.*)
76                 . = ALIGN (4);
77                 _edata = .;
78                 PROVIDE (__data_end = .);
79         } > ram
80
81         .bss :
82         {
83                 PROVIDE (__bss_start = .);
84                 *(.bss .bss.*)
85                 . = ALIGN(4);
86                 *(COMMON)
87                 . = ALIGN(4);
88                 PROVIDE (__bss_end = .);
89         } > ram
90
91         /*
92          * Allocated stack at the end of bss section.
93          * Data heap is allocate at end of stack.
94          */
95         PROVIDE (__msp_start = .);
96         . = ALIGN(8);
97         . += STACK_SIZE;
98         PROVIDE (__msp_end = .);
99
100         PROVIDE (__psp_start = .);
101         . = ALIGN(8);
102         . += STACK_SIZE;
103         PROVIDE (__psp_end = .);
104
105         PROVIDE (__heap_start = .);
106         . = ALIGN(8);
107 }