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