PR24786, wrong LMA if first section in overlay is empty
[external/binutils.git] / ld / scripttempl / elf32msp430_3.sc
1 # Copyright (C) 2014-2019 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
7 cat <<EOF
8 /* Copyright (C) 2014-2019 Free Software Foundation, Inc.
9
10    Copying and distribution of this script, with or without modification,
11    are permitted in any medium without royalty provided the copyright
12    notice and this notice are preserved.  */
13
14 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
15 OUTPUT_ARCH(${ARCH})
16
17 EOF
18
19 test -n "${RELOCATING}" && cat <<EOF
20 MEMORY
21 {
22   text   (rx)   : ORIGIN = $ROM_START,  LENGTH = $ROM_SIZE
23   data   (rwx)  : ORIGIN = $RAM_START,  LENGTH = $RAM_SIZE
24   vectors (rw)  : ORIGIN = 0xffe0,      LENGTH = 0x20
25 }
26
27 EOF
28
29 cat <<EOF
30 SECTIONS
31 {
32   /* Read-only sections, merged into text segment.  */
33   ${TEXT_DYNAMIC+${DYNAMIC}}
34   .hash        ${RELOCATING-0} : { *(.hash)             }
35   .dynsym      ${RELOCATING-0} : { *(.dynsym)           }
36   .dynstr      ${RELOCATING-0} : { *(.dynstr)           }
37   .gnu.version ${RELOCATING-0} : { *(.gnu.version)      }
38   .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)  }
39   .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)  }
40
41   .rel.init    ${RELOCATING-0} : { *(.rel.init) }
42   .rela.init   ${RELOCATING-0} : { *(.rela.init)        }
43   .rel.text    ${RELOCATING-0} :
44     {
45       *(.rel.text)
46       ${RELOCATING+*(.rel.text.*)}
47       ${RELOCATING+*(.rel.gnu.linkonce.t*)}
48     }
49   .rela.text   ${RELOCATING-0} :
50     {
51       *(.rela.text)
52       ${RELOCATING+*(.rela.text.*)}
53       ${RELOCATING+*(.rela.gnu.linkonce.t*)}
54     }
55   .rel.fini    ${RELOCATING-0} : { *(.rel.fini) }
56   .rela.fini   ${RELOCATING-0} : { *(.rela.fini)        }
57   .rel.rodata  ${RELOCATING-0} :
58     {
59       *(.rel.rodata)
60       ${RELOCATING+*(.rel.rodata.*)}
61       ${RELOCATING+*(.rel.gnu.linkonce.r*)}
62     }
63   .rela.rodata ${RELOCATING-0} :
64     {
65       *(.rela.rodata)
66       ${RELOCATING+*(.rela.rodata.*)}
67       ${RELOCATING+*(.rela.gnu.linkonce.r*)}
68     }
69   .rel.data    ${RELOCATING-0} :
70     {
71       *(.rel.data)
72       ${RELOCATING+*(.rel.data.*)}
73       ${RELOCATING+*(.rel.gnu.linkonce.d*)}
74     }
75   .rela.data   ${RELOCATING-0} :
76     {
77       *(.rela.data)
78       ${RELOCATING+*(.rela.data.*)}
79       ${RELOCATING+*(.rela.gnu.linkonce.d*)}
80     }
81   .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)        }
82   .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)       }
83   .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)        }
84   .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)       }
85   .rel.got     ${RELOCATING-0} : { *(.rel.got)          }
86   .rela.got    ${RELOCATING-0} : { *(.rela.got)         }
87   .rel.bss     ${RELOCATING-0} : { *(.rel.bss)          }
88   .rela.bss    ${RELOCATING-0} : { *(.rela.bss)         }
89   .rel.plt     ${RELOCATING-0} : { *(.rel.plt)          }
90   .rela.plt    ${RELOCATING-0} : { *(.rela.plt)         }
91
92   /* Internal text space.  */
93   .text :
94   {
95     ${RELOCATING+. = ALIGN(2);
96     *(SORT_NONE(.init))
97     *(SORT_NONE(.init0))  /* Start here after reset.  */
98     *(SORT_NONE(.init1))
99     *(SORT_NONE(.init2))
100     *(SORT_NONE(.init3))
101     *(SORT_NONE(.init4))
102     *(SORT_NONE(.init5))
103     *(SORT_NONE(.init6)) /* C++ constructors.  */
104     *(SORT_NONE(.init7))
105     *(SORT_NONE(.init8))
106     *(SORT_NONE(.init9))  /* Call main().  */}
107
108     ${CONSTRUCTING+ __ctors_start = . ; }
109     ${CONSTRUCTING+ *(.ctors) }
110     ${CONSTRUCTING+ __ctors_end = . ; }
111     ${CONSTRUCTING+ __dtors_start = . ; }
112     ${CONSTRUCTING+ *(.dtors) }
113     ${CONSTRUCTING+ __dtors_end = . ; }
114
115     ${RELOCATING+. = ALIGN(2);}
116     *(.text)
117     ${RELOCATING+. = ALIGN(2);
118     *(.text.*)
119     . = ALIGN(2);
120     *(.text:*)
121
122     . = ALIGN(2);
123     *(SORT_NONE(.fini9))
124     *(SORT_NONE(.fini8))
125     *(SORT_NONE(.fini7))
126     *(SORT_NONE(.fini6))  /* C++ destructors.  */
127     *(SORT_NONE(.fini5))
128     *(SORT_NONE(.fini4))
129     *(SORT_NONE(.fini3))
130     *(SORT_NONE(.fini2))
131     *(SORT_NONE(.fini1))
132     *(SORT_NONE(.fini0))  /* Infinite loop after program termination.  */
133     *(SORT_NONE(.fini))
134
135     _etext = . ;}
136   } ${RELOCATING+ > text}
137
138   .rodata :
139   {
140     *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*})
141     ${RELOCATING+*(.const)}
142     ${RELOCATING+*(.const:*)}
143   } ${RELOCATING+ > text}
144
145   .data ${RELOCATING-0} :
146   {
147     ${RELOCATING+ PROVIDE (__data_start = .) ; }
148     ${RELOCATING+. = ALIGN(2);}
149     *(.data)
150     ${RELOCATING+*(.data.*)}
151     ${RELOCATING+*(.gnu.linkonce.d*)}
152     ${RELOCATING+. = ALIGN(2);}
153     ${RELOCATING+ _edata = . ; }
154   } ${RELOCATING+ > data AT> text}
155
156   __romdatastart = LOADADDR(.data);
157   __romdatacopysize = SIZEOF(.data);
158
159   .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
160   {
161     ${RELOCATING+. = ALIGN(2);}
162     ${RELOCATING+ PROVIDE (__bss_start = .) ; }
163     ${RELOCATING+ PROVIDE (__bssstart = .); }
164     *(.bss)
165     *(COMMON)
166     ${RELOCATING+ PROVIDE (__bss_end = .) ; }
167   } ${RELOCATING+ > data}
168   ${RELOCATING+ PROVIDE (__bsssize = SIZEOF(.bss)); }
169
170   .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} :
171   {
172     ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
173     *(.noinit)
174     *(COMMON)
175     ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
176   } ${RELOCATING+ > data}
177
178   .persistent ${RELOCATING+ SIZEOF(.noinit) + ADDR(.noinit)} :
179   {
180     ${RELOCATING+ PROVIDE (__persistent_start = .) ; }
181     *(.persistent)
182     ${RELOCATING+ PROVIDE (__persistent_end = .) ; }
183   } ${RELOCATING+ > data}
184
185   ${RELOCATING+ _end = . ;}
186
187   .vectors ${RELOCATING-0}:
188   {
189     ${RELOCATING+ PROVIDE (__vectors_start = .) ; }
190     *(.vectors${RELOCATING+*})
191     ${RELOCATING+ _vectors_end = . ; }
192   } ${RELOCATING+ > vectors}
193
194   .MSP430.attributes 0 :
195   {
196     KEEP (*(.MSP430.attributes))
197     KEEP (*(.gnu.attributes))
198     KEEP (*(__TI_build_attributes))
199   }
200
201   /* Stabs debugging sections.  */
202   .stab 0 : { *(.stab) }
203   .stabstr 0 : { *(.stabstr) }
204   .stab.excl 0 : { *(.stab.excl) }
205   .stab.exclstr 0 : { *(.stab.exclstr) }
206   .stab.index 0 : { *(.stab.index) }
207   .stab.indexstr 0 : { *(.stab.indexstr) }
208   .comment 0 : { *(.comment) }
209
210 EOF
211
212 . $srcdir/scripttempl/DWARF.sc
213
214 test -n "${RELOCATING}" && cat <<EOF
215   PROVIDE (__stack = ${STACK}) ;
216   PROVIDE (__data_start_rom = _etext) ;
217   PROVIDE (__data_end_rom   = _etext + SIZEOF (.data)) ;
218   PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ;
219   PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ;
220 EOF
221
222 cat <<EOF
223 }
224 EOF