PR 6943
[external/binutils.git] / ld / scripttempl / avr.sc
1 cat <<EOF
2 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
3 OUTPUT_ARCH(${ARCH})
4
5 MEMORY
6 {
7   text   (rx)   : ORIGIN = 0, LENGTH = $TEXT_LENGTH
8   data   (rw!x) : ORIGIN = 0x800060, LENGTH = $DATA_LENGTH
9   eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
10 }
11
12 SECTIONS
13 {
14   /* Read-only sections, merged into text segment: */
15   ${TEXT_DYNAMIC+${DYNAMIC}}
16   .hash        ${RELOCATING-0} : { *(.hash)             }
17   .dynsym      ${RELOCATING-0} : { *(.dynsym)           }
18   .dynstr      ${RELOCATING-0} : { *(.dynstr)           }
19   .gnu.version ${RELOCATING-0} : { *(.gnu.version)      }
20   .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)  }
21   .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)  }
22
23   .rel.init    ${RELOCATING-0} : { *(.rel.init)         }
24   .rela.init   ${RELOCATING-0} : { *(.rela.init)        }
25   .rel.text    ${RELOCATING-0} :
26     {
27       *(.rel.text)
28       ${RELOCATING+*(.rel.text.*)}
29       ${RELOCATING+*(.rel.gnu.linkonce.t*)}
30     }
31   .rela.text   ${RELOCATING-0} :
32     {
33       *(.rela.text)
34       ${RELOCATING+*(.rela.text.*)}
35       ${RELOCATING+*(.rela.gnu.linkonce.t*)}
36     }
37   .rel.fini    ${RELOCATING-0} : { *(.rel.fini)         }
38   .rela.fini   ${RELOCATING-0} : { *(.rela.fini)        }
39   .rel.rodata  ${RELOCATING-0} :
40     {
41       *(.rel.rodata)
42       ${RELOCATING+*(.rel.rodata.*)}
43       ${RELOCATING+*(.rel.gnu.linkonce.r*)}
44     }
45   .rela.rodata ${RELOCATING-0} :
46     {
47       *(.rela.rodata)
48       ${RELOCATING+*(.rela.rodata.*)}
49       ${RELOCATING+*(.rela.gnu.linkonce.r*)}
50     }
51   .rel.data    ${RELOCATING-0} :
52     {
53       *(.rel.data)
54       ${RELOCATING+*(.rel.data.*)}
55       ${RELOCATING+*(.rel.gnu.linkonce.d*)}
56     }
57   .rela.data   ${RELOCATING-0} :
58     {
59       *(.rela.data)
60       ${RELOCATING+*(.rela.data.*)}
61       ${RELOCATING+*(.rela.gnu.linkonce.d*)}
62     }
63   .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)        }
64   .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)       }
65   .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)        }
66   .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)       }
67   .rel.got     ${RELOCATING-0} : { *(.rel.got)          }
68   .rela.got    ${RELOCATING-0} : { *(.rela.got)         }
69   .rel.bss     ${RELOCATING-0} : { *(.rel.bss)          }
70   .rela.bss    ${RELOCATING-0} : { *(.rela.bss)         }
71   .rel.plt     ${RELOCATING-0} : { *(.rel.plt)          }
72   .rela.plt    ${RELOCATING-0} : { *(.rela.plt)         }
73
74   /* Internal text space or external memory.  */
75   .text ${RELOCATING-0} :
76   {
77     *(.vectors)
78     KEEP(*(.vectors))
79
80     /* For data that needs to reside in the lower 64k of progmem.  */
81     *(.progmem.gcc*)
82     *(.progmem*)
83     ${RELOCATING+. = ALIGN(2);}
84
85     ${CONSTRUCTING+ __trampolines_start = . ; }
86     /* The jump trampolines for the 16-bit limited relocs will reside here.  */
87     *(.trampolines)
88     *(.trampolines*)
89     ${CONSTRUCTING+ __trampolines_end = . ; }
90
91     /* For future tablejump instruction arrays for 3 byte pc devices.
92        We don't relax jump/call instructions within these sections.  */
93     *(.jumptables) 
94     *(.jumptables*) 
95
96     /* For code that needs to reside in the lower 128k progmem.  */
97     *(.lowtext)
98     *(.lowtext*)
99
100     ${CONSTRUCTING+ __ctors_start = . ; }
101     ${CONSTRUCTING+ *(.ctors) }
102     ${CONSTRUCTING+ __ctors_end = . ; }
103     ${CONSTRUCTING+ __dtors_start = . ; }
104     ${CONSTRUCTING+ *(.dtors) }
105     ${CONSTRUCTING+ __dtors_end = . ; }
106     KEEP(SORT(*)(.ctors))
107     KEEP(SORT(*)(.dtors))
108
109     /* From this point on, we don't bother about wether the insns are
110        below or above the 16 bits boundary.  */
111     *(.init0)  /* Start here after reset.  */
112     KEEP (*(.init0))
113     *(.init1)
114     KEEP (*(.init1))
115     *(.init2)  /* Clear __zero_reg__, set up stack pointer.  */
116     KEEP (*(.init2))
117     *(.init3)
118     KEEP (*(.init3))
119     *(.init4)  /* Initialize data and BSS.  */
120     KEEP (*(.init4))
121     *(.init5)
122     KEEP (*(.init5))
123     *(.init6)  /* C++ constructors.  */
124     KEEP (*(.init6))
125     *(.init7)
126     KEEP (*(.init7))
127     *(.init8)
128     KEEP (*(.init8))
129     *(.init9)  /* Call main().  */
130     KEEP (*(.init9))
131     *(.text)
132     ${RELOCATING+. = ALIGN(2);}
133     *(.text.*)
134     ${RELOCATING+. = ALIGN(2);}
135     *(.fini9)  /* _exit() starts here.  */
136     KEEP (*(.fini9))
137     *(.fini8)
138     KEEP (*(.fini8))
139     *(.fini7)
140     KEEP (*(.fini7))
141     *(.fini6)  /* C++ destructors.  */
142     KEEP (*(.fini6))
143     *(.fini5)
144     KEEP (*(.fini5))
145     *(.fini4)
146     KEEP (*(.fini4))
147     *(.fini3)
148     KEEP (*(.fini3))
149     *(.fini2)
150     KEEP (*(.fini2))
151     *(.fini1)
152     KEEP (*(.fini1))
153     *(.fini0)  /* Infinite loop after program termination.  */
154     KEEP (*(.fini0))
155     ${RELOCATING+ _etext = . ; }
156   } ${RELOCATING+ > text}
157
158   .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))}
159   {
160     ${RELOCATING+ PROVIDE (__data_start = .) ; }
161     *(.data)
162     *(.data*)
163     *(.rodata)  /* We need to include .rodata here if gcc is used */
164     *(.rodata*) /* with -fdata-sections.  */
165     *(.gnu.linkonce.d*)
166     ${RELOCATING+. = ALIGN(2);}
167     ${RELOCATING+ _edata = . ; }
168     ${RELOCATING+ PROVIDE (__data_end = .) ; }
169   } ${RELOCATING+ > data}
170
171   .bss ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
172   {
173     ${RELOCATING+ PROVIDE (__bss_start = .) ; }
174     *(.bss)
175     *(.bss*)
176     *(COMMON)
177     ${RELOCATING+ PROVIDE (__bss_end = .) ; }
178   } ${RELOCATING+ > data}
179
180   ${RELOCATING+ __data_load_start = LOADADDR(.data); }
181   ${RELOCATING+ __data_load_end = __data_load_start + SIZEOF(.data); }
182
183   /* Global data not cleared after reset.  */
184   .noinit ${RELOCATING-0}:
185   {
186     ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
187     *(.noinit*)
188     ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
189     ${RELOCATING+ _end = . ;  }
190     ${RELOCATING+ PROVIDE (__heap_start = .) ; }
191   } ${RELOCATING+ > data}
192
193   .eeprom ${RELOCATING-0}:
194   {
195     *(.eeprom*)
196     ${RELOCATING+ __eeprom_end = . ; }
197   } ${RELOCATING+ > eeprom}
198
199   /* Stabs debugging sections.  */
200   .stab 0 : { *(.stab) }
201   .stabstr 0 : { *(.stabstr) }
202   .stab.excl 0 : { *(.stab.excl) }
203   .stab.exclstr 0 : { *(.stab.exclstr) }
204   .stab.index 0 : { *(.stab.index) }
205   .stab.indexstr 0 : { *(.stab.indexstr) }
206   .comment 0 : { *(.comment) }
207  
208   /* DWARF debug sections.
209      Symbols in the DWARF debugging sections are relative to the beginning
210      of the section so we begin them at 0.  */
211
212   /* DWARF 1 */
213   .debug          0 : { *(.debug) }
214   .line           0 : { *(.line) }
215
216   /* GNU DWARF 1 extensions */
217   .debug_srcinfo  0 : { *(.debug_srcinfo) }
218   .debug_sfnames  0 : { *(.debug_sfnames) }
219
220   /* DWARF 1.1 and DWARF 2 */
221   .debug_aranges  0 : { *(.debug_aranges) }
222   .debug_pubnames 0 : { *(.debug_pubnames) }
223
224   /* DWARF 2 */
225   .debug_info     0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
226   .debug_abbrev   0 : { *(.debug_abbrev) }
227   .debug_line     0 : { *(.debug_line) }
228   .debug_frame    0 : { *(.debug_frame) }
229   .debug_str      0 : { *(.debug_str) }
230   .debug_loc      0 : { *(.debug_loc) }
231   .debug_macinfo  0 : { *(.debug_macinfo) }
232 }
233 EOF
234