* scripttempl/elf.sc: Handle function names and other
[external/binutils.git] / ld / scripttempl / elf32msp430_3.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 = $ROM_START,  LENGTH = $ROM_SIZE
8   data   (rwx)  : ORIGIN = $RAM_START,  LENGTH = $RAM_SIZE
9   vectors (rw)  : ORIGIN = 0xffe0,      LENGTH = 0x20
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.  */
75   .text :
76   {
77     ${RELOCATING+. = ALIGN(2);}
78     *(SORT_NONE(.init))
79     *(SORT_NONE(.init0))  /* Start here after reset.  */
80     *(SORT_NONE(.init1))
81     *(SORT_NONE(.init2))
82     *(SORT_NONE(.init3))
83     *(SORT_NONE(.init4))
84     *(SORT_NONE(.init5))
85     *(SORT_NONE(.init6)) /* C++ constructors.  */
86     *(SORT_NONE(.init7))
87     *(SORT_NONE(.init8))
88     *(SORT_NONE(.init9))  /* Call main().  */
89
90     ${CONSTRUCTING+ __ctors_start = . ; }
91     ${CONSTRUCTING+ *(.ctors) }
92     ${CONSTRUCTING+ __ctors_end = . ; }
93     ${CONSTRUCTING+ __dtors_start = . ; }
94     ${CONSTRUCTING+ *(.dtors) }
95     ${CONSTRUCTING+ __dtors_end = . ; }
96
97     ${RELOCATING+. = ALIGN(2);}
98     *(.text)
99     ${RELOCATING+. = ALIGN(2);}
100     *(.text.*)
101     ${RELOCATING+. = ALIGN(2);}
102     *(.text:*)
103
104     ${RELOCATING+. = ALIGN(2);}
105     *(SORT_NONE(.fini9))
106     *(SORT_NONE(.fini8))
107     *(SORT_NONE(.fini7))
108     *(SORT_NONE(.fini6))  /* C++ destructors.  */
109     *(SORT_NONE(.fini5))
110     *(SORT_NONE(.fini4))
111     *(SORT_NONE(.fini3))
112     *(SORT_NONE(.fini2))
113     *(SORT_NONE(.fini1))
114     *(SORT_NONE(.fini0))  /* Infinite loop after program termination.  */
115     *(SORT_NONE(.fini))
116
117     ${RELOCATING+ _etext = . ; }
118   } ${RELOCATING+ > text}
119
120   .rodata :
121   {
122     *(.rodata .rodata.* .gnu.linkonce.r.*)
123     *(.const)
124     *(.const:*)
125   } ${RELOCATING+ > text}
126
127   .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))}
128   {  
129     ${RELOCATING+ PROVIDE (__data_start = .) ; }
130     ${RELOCATING+. = ALIGN(2);}
131     *(.data)
132     *(.data.*)
133     *(.gnu.linkonce.d*)
134     ${RELOCATING+. = ALIGN(2);}
135     ${RELOCATING+ _edata = . ; }
136   } ${RELOCATING+ > data}
137   
138   .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
139   {
140     ${RELOCATING+. = ALIGN(2);}
141     ${RELOCATING+ PROVIDE (__bss_start = .) ; }
142     *(.bss)
143     *(COMMON)
144     ${RELOCATING+ PROVIDE (__bss_end = .) ; }
145     ${RELOCATING+ _end = . ;  }
146   } ${RELOCATING+ > data}
147
148   .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} :
149   {
150     ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
151     *(.noinit)
152     *(COMMON)
153     ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
154     ${RELOCATING+ _end = . ;  }
155   } ${RELOCATING+ > data}
156
157   .vectors ${RELOCATING-0}:
158   {
159     ${RELOCATING+ PROVIDE (__vectors_start = .) ; }
160     *(.vectors*)
161     ${RELOCATING+ _vectors_end = . ; }
162   } ${RELOCATING+ > vectors}
163
164   .MP430.attributes 0 :
165   {
166     KEEP (*(.MSP430.attributes))
167     KEEP (*(.gnu.attributes))
168     KEEP (*(__TI_build_attributes))
169   }
170
171   /* Stabs debugging sections.  */
172   .stab 0 : { *(.stab) } 
173   .stabstr 0 : { *(.stabstr) }
174   .stab.excl 0 : { *(.stab.excl) }
175   .stab.exclstr 0 : { *(.stab.exclstr) }
176   .stab.index 0 : { *(.stab.index) }
177   .stab.indexstr 0 : { *(.stab.indexstr) }
178   .comment 0 : { *(.comment) }
179  
180 EOF
181
182 . $srcdir/scripttempl/DWARF.sc
183
184 cat <<EOF
185   PROVIDE (__stack = ${STACK}) ;
186   PROVIDE (__data_start_rom = _etext) ;
187   PROVIDE (__data_end_rom   = _etext + SIZEOF (.data)) ;
188   PROVIDE (__noinit_start_rom = _etext + SIZEOF (.data)) ;
189   PROVIDE (__noinit_end_rom = _etext + SIZEOF (.data) + SIZEOF (.noinit)) ;
190 }
191 EOF