]> rtime.felk.cvut.cz Git - sysless.git/blob - board/arm/oc8n/libs/ldscripts/at91sam7.ld-flash
Make arm/oc8n compilable
[sysless.git] / board / arm / oc8n / libs / ldscripts / at91sam7.ld-flash
1 /* ****************************************************************************************************** */
2 /*   demo_at91sam7_blink_flash.cmd                      LINKER  SCRIPT                                                */
3 /*                                                                                                        */
4 /*                                                                                                        */
5 /*   The Linker Script defines how the code and data emitted by the GNU C compiler and assembler are      */
6 /*   to be loaded into memory (code goes into FLASH, variables go into RAM).                                              */
7 /*                                                                                                        */
8 /*   Any symbols defined in the Linker Script are automatically global and available to the rest of the   */
9 /*   program.                                                                                             */
10 /*                                                                                                        */
11 /*   To force the linker to use this LINKER SCRIPT, just add the -T demo_at91sam7_blink_flash.cmd         */
12 /*   directive to the linker flags in the makefile. For example,                                          */
13 /*                                                                                                        */
14 /*                      LFLAGS  =  -Map main.map -nostartfiles -T demo_at91sam7_blink_flash.cmd                   */
15 /*                                                                                                        */
16 /*                                                                                                        */
17 /*   The order that the object files are listed in the makefile determines what .text section is          */
18 /*   placed first.                                                                                        */
19 /*                                                                                                        */
20 /*   For example:  $(LD) $(LFLAGS) -o main.out  crt.o main.o lowlevelinit.o                               */
21 /*                                                                                                        */
22 /*                         crt.o is first in the list of objects, so it will be placed at address 0x00000000      */
23 /*                                                                                                        */
24 /*                                                                                                        */
25 /*   The top of the stack (_stack_end) is (last_byte_of_ram +1) - 4                                                   */
26 /*                                                                                                        */
27 /*   Therefore:   _stack_end = (0x00020FFFF + 1) - 4  =  0x00021000 - 4  =  0x0020FFFC                    */
28 /*                                                                                                        */
29 /*   Note that this symbol (_stack_end) is automatically GLOBAL and will be used by the crt.s             */
30 /*   startup assembler routine to specify all stacks for the various ARM modes                            */
31 /*                                                                                                        */
32 /*                              MEMORY MAP                                                                */
33 /*                      |                                 |                                               */
34 /*            .-------->|---------------------------------|0x00210000                                     */
35 /*            .         |                                 |0x0020FFFC  <---------- _stack_end             */
36 /*            .         |    UDF Stack  16 bytes          |                                               */
37 /*            .         |                                 |                                               */
38 /*            .         |---------------------------------|0x0020FFEC                                     */
39 /*            .         |                                 |                                               */
40 /*            .         |    ABT Stack  16 bytes          |                                               */
41 /*            .         |                                 |                                               */
42 /*            .         |---------------------------------|0x0020FFDC                                     */
43 /*            .         |                                 |                                               */
44 /*            .         |                                 |                                               */
45 /*            .         |    FIQ Stack  128 bytes         |                                               */
46 /*            .         |                                 |                                               */
47 /*            .         |                                 |                                               */
48 /*           RAM        |---------------------------------|0x0020FF5C                                     */
49 /*            .         |                                 |                                               */
50 /*            .         |                                 |                                               */
51 /*            .         |    IRQ Stack  128 bytes         |                                               */
52 /*            .         |                                 |                                               */
53 /*            .         |                                 |                                               */
54 /*            .         |---------------------------------|0x0020FEDC                                     */
55 /*            .         |                                 |                                               */
56 /*            .         |    SVC Stack  16 bytes          |                                               */
57 /*            .         |                                 |                                               */
58 /*            .         |---------------------------------|0x0020FECC                                     */
59 /*            .         |                                 |                                                       */
60 /*            .         |     stack area for user program |                                               */
61 /*            .         |                                 |                                               */
62 /*            .         |                                 |                                               */
63 /*            .         |                                 |                                               */
64 /*            .         |          free ram               |                                               */
65 /*            .         |                                 |                                               */
66 /*            .         |.................................|0x002006D8 <---------- _bss_end                */
67 /*            .         |                                 |                                               */
68 /*            .         |  .bss   uninitialized variables |                                               */
69 /*            .         |.................................|0x002006D0 <---------- _bss_start, _edata      */
70 /*            .         |                                 |                                               */
71 /*            .         |  .data  initialized variables   |                                               */
72 /*            .         |                                 |                                               */
73 /*            .-------->|_________________________________|0x00200000                                     */
74 /*                                                                                                        */
75 /*                                                                                                        */
76 /*            .-------->|---------------------------------|0x00100000                                     */
77 /*            .         |                                 |                                               */
78 /*            .         |                                 |                                               */
79 /*            .         |         free flash              |                                               */
80 /*            .         |                                 |                                               */
81 /*            .         |                                 |                                               */
82 /*            .         |.................................|0x000006D0 <---------- _bss_start, _edata      */
83 /*            .         |                                 |                                               */
84 /*            .         |  .data  initialized variables   |                                               */
85 /*            .         |                                 |                                               */
86 /*            .         |---------------------------------|0x000006C4 <----------- _etext                 */
87 /*            .         |                                 |                                               */
88 /*            .         |            C code               |                                               */
89 /*            .         |                                 |                                               */
90 /*            .         |                                 |                                               */
91 /*            .         |---------------------------------|0x00000118  main()                             */
92 /*            .         |                                 |                                               */
93 /*            .         |    Startup Code  (crt.s)        |                                               */
94 /*            .         |         (assembler)             |                                               */
95 /*            .         |                                 |                                               */
96 /*            .         |---------------------------------|0x00000020                                     */
97 /*            .         |                                 |                                               */
98 /*            .         | Interrupt Vector Table          |                                               */
99 /*            .         |          32 bytes               |                                               */
100 /*            .-------->|---------------------------------|0x00000000 _vec_reset                            *
101 /*                                                                                                        */
102 /*                                                                                                        */
103 /*  Author:  James P. Lynch                                                                               */
104 /*                                                                                                        */
105 /* ****************************************************************************************************** */
106
107
108 /* identify the Entry Point  (_vec_reset is defined in file crt.s)  */
109 ENTRY(_vec_reset)
110
111 /* specify the LPC2106 memory areas  */
112
113 /* if you find this file hard to understand, this may help: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_chapter/ld_3.html#SEC5 */
114
115 MEMORY 
116 {
117         flash   : ORIGIN = 0,          LENGTH = 256K    /* FLASH EPROM          */      
118         ram             : ORIGIN = 0x00200000, LENGTH = 64K     /* static RAM area      */
119 }
120
121
122 /* define a global symbol _stack_end  (see analysis in annotation above) */
123 _stack_end = 0x20FFFC;
124
125 /* now define the output sections  */
126 SECTIONS 
127 {
128         . = 0;                                                          /* set location counter to address zero  */
129         
130         .zeropage :
131         {
132                 *(.zeropage)                    /* the .zeropage section put at the beginning  */ 
133         } > flash
134
135         .text :                                                         /* collect all sections that should go into FLASH after startup  */ 
136         {
137                 *(.text)                                                /* all .text sections (code)  */
138                 *(.rodata)                                              /* all .rodata sections (constants, strings, etc.)  */
139                 *(.rodata*)                                             /* all .rodata* sections (constants, strings, etc.)  */
140                 *(.glue_7)                                              /* all .glue_7 sections  (no idea what these are) */
141                 *(.glue_7t)                                             /* all .glue_7t sections (no idea what these are) */
142                 _etext = .;                                             /* define a global symbol _etext just after the last code byte */
143         } >flash                                                        /* put all the above into FLASH */
144
145         .data :                                                         /* collect all initialized .data sections that go into RAM  */ 
146         {
147                 _data = .;                                              /* create a global symbol marking the start of the .data section  */
148                 *(.data)                                                /* all .data sections  */
149                 _edata = .;                                             /* define a global symbol marking the end of the .data section  */
150         } >ram AT >flash                                /* put all the above into RAM (but load the LMA initializer copy into FLASH)  */
151
152         .bss :                                                          /* collect all uninitialized .bss sections that go into RAM  */
153         {
154                 _bss_start = .;                                 /* define a global symbol marking the start of the .bss section */
155                 *(.bss)                                                 /* all .bss sections  */
156         } >ram                                                          /* put all the above in RAM (it will be cleared in the startup code */
157
158         . = ALIGN(4);                                           /* advance location counter to the next 32-bit boundary */
159         _bss_end = . ;                                          /* define a global symbol marking the end of the .bss section */
160 }
161         _end = .;                                                       /* define a global symbol marking the end of application RAM */
162         PROVIDE (end = .);