1# Copyright (C) 2014-2017 Free Software Foundation, Inc.
2# 
3# Copying and distribution of this file, with or without modification,
4# are permitted in any medium without royalty provided the copyright
5# notice and this notice are preserved.
6
7CTOR=".ctors ${CONSTRUCTING-0} : 
8  {
9    ${CONSTRUCTING+ __CTOR_LIST__ = .; }
10    /* gcc uses crtbegin.o to find the start of
11       the constructors, so we make sure it is
12       first.  Because this is a wildcard, it
13       doesn't matter if the user does not
14       actually link against crtbegin.o; the
15       linker won't look for a file to match a
16       wildcard.  The wildcard also means that it
17       doesn't matter which directory crtbegin.o
18       is in.  */
19
20    KEEP (*crtbegin.o(.ctors))
21    KEEP (*crtbegin?.o(.ctors))
22
23    /* We don't want to include the .ctor section from
24       the crtend.o file until after the sorted ctors.
25       The .ctor section from the crtend file contains the
26       end of ctors marker and it must be last */
27
28    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))
29    KEEP (*(SORT(.ctors.*)))
30    KEEP (*(.ctors))
31    ${CONSTRUCTING+ __CTOR_END__ = .; }
32  } ${RELOCATING+ > ${DATA_MEMORY}}"
33
34DTOR="  .dtors	${CONSTRUCTING-0} :
35  {
36    ${CONSTRUCTING+ __DTOR_LIST__ = .; }
37    KEEP (*crtbegin.o(.dtors))
38    KEEP (*crtbegin?.o(.dtors))
39    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))
40    KEEP (*(SORT(.dtors.*)))
41    KEEP (*(.dtors))
42    ${CONSTRUCTING+ __DTOR_END__ = .; }
43  } ${RELOCATING+ > ${DATA_MEMORY}}"
44
45cat <<EOF
46/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
47
48   Copying and distribution of this script, with or without modification,
49   are permitted in any medium without royalty provided the copyright
50   notice and this notice are preserved.  */
51
52OUTPUT_FORMAT("${OUTPUT_FORMAT}")
53OUTPUT_ARCH(${ARCH})
54
55MEMORY
56{
57  text ${TEXT_DEF_SECTION} : ORIGIN = ${TEXT_START_ADDR}, LENGTH = ${TEXT_SIZE}
58  data ${DATA_DEF_SECTION} : ORIGIN = ${DATA_START_ADDR}, LENGTH = ${DATA_SIZE}
59  emem ${EMEM_DEF_SECTION} : ORIGIN = ${EMEM_START_ADDR}, LENGTH = ${EMEM_SIZE}
60  eit			   : ORIGIN = ${EIT_START_ADDR},  LENGTH = ${EIT_SIZE}
61}
62
63SECTIONS
64{
65  /* Read-only sections, merged into text segment: */
66  ${TEXT_DYNAMIC+${DYNAMIC}}
67  .hash			${RELOCATING-0} : { *(.hash) }
68  .dynsym		${RELOCATING-0} : { *(.dynsym) }
69  .dynstr		${RELOCATING-0} : { *(.dynstr) }
70  .gnu.version		${RELOCATING-0} : { *(.gnu.version) }
71  .gnu.version_d	${RELOCATING-0} : { *(.gnu.version_d) }
72  .gnu.version_r	${RELOCATING-0} : { *(.gnu.version_r) }
73
74  .rel.text		${RELOCATING-0} : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
75  .rela.text		${RELOCATING-0} : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
76  .rel.data		${RELOCATING-0} : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
77  .rela.data		${RELOCATING-0} : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
78  .rel.rodata		${RELOCATING-0} : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
79  .rela.rodata		${RELOCATING-0} : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
80  .rel.stext		${RELOCATING-0} : { *(.rel.stest) }
81  .rela.stext		${RELOCATING-0} : { *(.rela.stest) }
82  .rel.etext		${RELOCATING-0} : { *(.rel.etest) }
83  .rela.etext		${RELOCATING-0} : { *(.rela.etest) }
84  .rel.sdata		${RELOCATING-0} : { *(.rel.sdata) }
85  .rela.sdata		${RELOCATING-0} : { *(.rela.sdata) }
86  .rel.edata		${RELOCATING-0} : { *(.rel.edata) }
87  .rela.edata		${RELOCATING-0} : { *(.rela.edata) }
88  .rel.eit_v		${RELOCATING-0} : { *(.rel.eit_v) }
89  .rela.eit_v		${RELOCATING-0} : { *(.rela.eit_v) }
90  .rel.sbss		${RELOCATING-0} : { *(.rel.sbss) }
91  .rela.sbss		${RELOCATING-0} : { *(.rela.sbss) }
92  .rel.ebss		${RELOCATING-0} : { *(.rel.ebss) }
93  .rela.ebss		${RELOCATING-0} : { *(.rela.ebss) }
94  .rel.srodata		${RELOCATING-0} : { *(.rel.srodata) }
95  .rela.srodata		${RELOCATING-0} : { *(.rela.srodata) }
96  .rel.erodata		${RELOCATING-0} : { *(.rel.erodata) }
97  .rela.erodata		${RELOCATING-0} : { *(.rela.erodata) }
98  .rel.got		${RELOCATING-0} : { *(.rel.got) }
99  .rela.got		${RELOCATING-0} : { *(.rela.got) }
100  .rel.ctors		${RELOCATING-0} : { *(.rel.ctors) }
101  .rela.ctors		${RELOCATING-0} : { *(.rela.ctors) }
102  .rel.dtors		${RELOCATING-0} : { *(.rel.dtors) }
103  .rela.dtors		${RELOCATING-0} : { *(.rela.dtors) }
104  .rel.init		${RELOCATING-0} : { *(.rel.init) }
105  .rela.init		${RELOCATING-0} : { *(.rela.init) }
106  .rel.fini		${RELOCATING-0} : { *(.rel.fini) }
107  .rela.fini		${RELOCATING-0} : { *(.rela.fini) }
108  .rel.bss		${RELOCATING-0} : { *(.rel.bss) }
109  .rela.bss		${RELOCATING-0} : { *(.rela.bss) }
110  .rel.plt		${RELOCATING-0} : { *(.rel.plt) }
111  .rela.plt		${RELOCATING-0} : { *(.rela.plt) }
112
113  .init			${RELOCATING-0} : { *(.init) } =${NOP-0}
114  ${DATA_PLT-${PLT}}
115
116  /* Internal text space */
117  .stext	${RELOCATING-0} : { *(.stext) }		${RELOCATING+ > text}
118
119  /* Internal text space or external memory */
120  .text :
121  {
122    *(.text)
123    *(.gnu.linkonce.t*)
124    *(SORT_NONE(.init))
125    *(SORT_NONE(.fini))
126    ${RELOCATING+ _etext = . ; }
127  } ${RELOCATING+ > ${TEXT_MEMORY}}
128
129  /* Internal data space */
130  .srodata	${RELOCATING-0} : { *(.srodata) }	${RELOCATING+ > data}
131  .sdata	${RELOCATING-0} : { *(.sdata) }		${RELOCATING+ > data}
132
133  /* Internal data space or external memory */
134  .rodata	${RELOCATING-0} : { *(.rodata) }	${RELOCATING+ > ${DATA_MEMORY}}
135
136  /* C++ exception support.  */
137  .eh_frame	${RELOCATING-0} : { KEEP (*(.eh_frame)) }	${RELOCATING+ > ${DATA_MEMORY}}
138  .gcc_except_table ${RELOCATING-0} : { *(.gcc_except_table) }	${RELOCATING+ > ${DATA_MEMORY}}
139
140  /* Java class registration support.  */
141  .jcr		${RELOCATING-0} : { KEEP (*(.jcr)) }	${RELOCATING+ >${DATA_MEMORY}}
142
143  ${RELOCATING+${CTOR}}
144  ${RELOCATING+${DTOR}}
145
146  .data		${RELOCATING-0} :
147  {
148    *(.data)
149    *(.gnu.linkonce.d*)
150    ${CONSTRUCTING+CONSTRUCTORS}
151    ${RELOCATING+ _edata = . ; }
152  } ${RELOCATING+ > ${DATA_MEMORY}}
153
154  /* External memory */
155  .etext	${RELOCATING-0} :
156  {
157    ${RELOCATING+ PROVIDE (__etext_start = .) ; }
158    *(.etext)
159    ${RELOCATING+ PROVIDE (__etext_end = .) ; }
160  } ${RELOCATING+ > emem}
161
162  .erodata	${RELOCATING-0} : { *(.erodata) }	${RELOCATING+ > emem}
163  .edata	${RELOCATING-0} : { *(.edata) }		${RELOCATING+ > emem}
164
165  .sbss		${RELOCATING-0} :
166  {
167    ${RELOCATING+ PROVIDE (__sbss_start = .) ; }
168    *(.sbss)
169    ${RELOCATING+ PROVIDE (__sbss_end = .) ;  }
170  } ${RELOCATING+ > data}
171
172  .ebss		${RELOCATING-0} :
173  {
174    ${RELOCATING+ PROVIDE (__ebss_start = .) ; }
175    *(.ebss)
176    ${RELOCATING+ PROVIDE (__ebss_end = .) ;  }
177  } ${RELOCATING+ > data}
178
179  .bss		${RELOCATING-0} :
180  {
181    ${RELOCATING+ PROVIDE (__bss_start = .) ; }
182    *(.bss)
183    *(COMMON)
184    ${RELOCATING+ PROVIDE (__bss_end = .) ; }
185    ${RELOCATING+ _end = . ;  }
186  } ${RELOCATING+ > ${DATA_MEMORY}}
187
188  .eit_v	${RELOCATING-0} :
189  {
190    ${RELOCATING+ PROVIDE (__eit_start = .) ; }
191    *(.eit_v)
192    ${RELOCATING+ PROVIDE (__eit_end = .) ; }
193  } ${RELOCATING+ > eit}
194
195  /* Stabs debugging sections.  */
196  .stab		 0 : { *(.stab) }
197  .stabstr	 0 : { *(.stabstr) }
198  .stab.excl	 0 : { *(.stab.excl) }
199  .stab.exclstr	 0 : { *(.stab.exclstr) }
200  .stab.index	 0 : { *(.stab.index) }
201  .stab.indexstr 0 : { *(.stab.indexstr) }
202
203  .comment	 0 : { *(.comment) }
204
205EOF
206
207. $srcdir/scripttempl/DWARF.sc
208
209cat <<EOF  
210  PROVIDE (__stack = ${STACK_START_ADDR});
211}
212EOF
213
214
215
216
217