* emulparams/hppa64linux.sh (LARGE_SECTIONS): Remove .tbss.
[binutils.git] / ld / scripttempl / elf32sh-symbian.sc
blob1f87c2add6289091eef823928fd98004d9f97e42
2 # Unusual variables checked by this code:
3 #       NOP - four byte opcode for no-op (defaults to 0)
4 #       DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
5 #       INITIAL_READONLY_SECTIONS - at start of text segment
6 #       OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
7 #               (e.g., .PARISC.milli)
8 #       OTHER_TEXT_SECTIONS - these get put in .text when relocating
9 #       OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
10 #               (e.g., .PARISC.global)
11 #       OTHER_SECTIONS - at the end
12 #       EXECUTABLE_SYMBOLS - symbols that must be defined for an
13 #               executable (e.g., _DYNAMIC_LINK)
14 #       TEXT_START_SYMBOLS - symbols that appear at the start of the
15 #               .text section.
16 #       DATA_START_SYMBOLS - symbols that appear at the start of the
17 #               .data section.
18 #       OTHER_GOT_SYMBOLS - symbols defined just before .got.
19 #       OTHER_GOT_SECTIONS - sections just after .got.
20 #       OTHER_SDATA_SECTIONS - sections just after .sdata.
21 #       OTHER_BSS_SYMBOLS - symbols that appear at the start of the
22 #               .bss section besides __bss_start.
23 #       DATA_PLT - .plt should be in data segment, not text segment.
24 #       BSS_PLT - .plt should be in bss segment
25 #       TEXT_DYNAMIC - .dynamic in text segment, not data segment.
26 #       EMBEDDED - whether this is for an embedded system. 
27 #       SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set
28 #               start address of shared library.
29 #       INPUT_FILES - INPUT command of files to always include
30 #       WRITABLE_RODATA - if set, the .rodata section should be writable
31 #       INIT_START, INIT_END -  statements just before and just after
32 #       combination of .init sections.
33 #       FINI_START, FINI_END - statements just before and just after
34 #       combination of .fini sections.
35 #       STACK_ADDR - start of a .stack section.
36 #       OTHER_SYMBOLS - symbols to place right at the end of the script.
38 # When adding sections, do note that the names of some sections are used
39 # when specifying the start address of the next.
42 #  Many sections come in three flavours.  There is the 'real' section,
43 #  like ".data".  Then there are the per-procedure or per-variable
44 #  sections, generated by -ffunction-sections and -fdata-sections in GCC,
45 #  and useful for --gc-sections, which for a variable "foo" might be
46 #  ".data.foo".  Then there are the linkonce sections, for which the linker
47 #  eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
48 #  The exact correspondences are:
50 #  Section      Linkonce section
51 #  .text        .gnu.linkonce.t.foo
52 #  .rodata      .gnu.linkonce.r.foo
53 #  .data        .gnu.linkonce.d.foo
54 #  .bss         .gnu.linkonce.b.foo
55 #  .sdata       .gnu.linkonce.s.foo
56 #  .sbss        .gnu.linkonce.sb.foo
57 #  .sdata2      .gnu.linkonce.s2.foo
58 #  .sbss2       .gnu.linkonce.sb2.foo
59 #  .debug_info  .gnu.linkonce.wi.foo
60 #  .tdata       .gnu.linkonce.td.foo
61 #  .tbss        .gnu.linkonce.tb.foo
63 #  Each of these can also have corresponding .rel.* and .rela.* sections.
65 test -z "$ENTRY" && ENTRY=_start
66 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
67 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
68 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
69 test -z "${ELFSIZE}" && ELFSIZE=32
70 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
71 test "$LD_FLAG" = "N" && DATA_ADDR=.
72 test -n "$CREATE_SHLIB$CREATE_PIE" && test -n "$SHLIB_DATA_ADDR" && COMMONPAGESIZE=""
73 test -z "$CREATE_SHLIB$CREATE_PIE" && test -n "$DATA_ADDR" && COMMONPAGESIZE=""
74 DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
75 DATA_SEGMENT_END=""
76 if test -n "${COMMONPAGESIZE}"; then
77   DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})"
78   DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);"
80  INTERP=".interp    ALIGN(4) : { *(.interp) }"
81     PLT=".plt            : { *(.plt) } :dynamic :dyn"
82 DYNAMIC=".dynamic        : { *(.dynamic) } :dynamic :dyn"
83  RODATA=".rodata    ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
84 STACKNOTE="/DISCARD/ : { *(.note.GNU-stack)  *(.directive) }"
85 test -z "$GOT" && GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
86 CTOR=".ctors     ALIGN(4) : 
87   {
88     ${CONSTRUCTING+${CTOR_START}}
89     /* gcc uses crtbegin.o to find the start of
90        the constructors, so we make sure it is
91        first.  Because this is a wildcard, it
92        doesn't matter if the user does not
93        actually link against crtbegin.o; the
94        linker won't look for a file to match a
95        wildcard.  The wildcard also means that it
96        doesn't matter which directory crtbegin.o
97        is in.  */
99     KEEP (*crtbegin*.o(.ctors))
101     /* We don't want to include the .ctor section from
102        from the crtend.o file until after the sorted ctors.
103        The .ctor section from the crtend file contains the
104        end of ctors marker and it must be last */
106     KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
107     KEEP (*(SORT(.ctors.*)))
108     KEEP (*(.ctors))
109     ${CONSTRUCTING+${CTOR_END}}
110   } :text"
111 DTOR=".dtors        ALIGN(4) :
112   {
113     ${CONSTRUCTING+${DTOR_START}}
114     KEEP (*crtbegin*.o(.dtors))
115     KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
116     KEEP (*(SORT(.dtors.*)))
117     KEEP (*(.dtors))
118     ${CONSTRUCTING+${DTOR_END}}
119   } :text"
120 STACK="  .stack        ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} :
121   {
122     ${RELOCATING+_stack = .;}
123     *(.stack)
124   } :data"
126 # if this is for an embedded system, don't add SIZEOF_HEADERS.
127 if [ -z "$EMBEDDED" ]; then
128    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
129 else
130    test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
133 cat <<EOF
134 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
135               "${LITTLE_OUTPUT_FORMAT}")
136 OUTPUT_ARCH(${OUTPUT_ARCH})
137 ENTRY(${ENTRY})
139 ${RELOCATING+${LIB_SEARCH_DIRS}}
140 ${RELOCATING+/* Do we need any of these for elf?
141    __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}}  */}
142 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
143 ${RELOCATING+${INPUT_FILES}}
144 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
145   if gld -r is used and the intermediate file has sections starting
146   at non-zero addresses.  Could be a Solaris ld bug, could be a GNU ld
147   bug.  But for now assigning the zero vmas works.  */}
149 PHDRS
151   headers PT_PHDR PHDRS ;
152   text    PT_LOAD ;
153   data    PT_LOAD ;
154   dyn     PT_LOAD FLAGS (0) ;
155   dynamic PT_DYNAMIC ;
158 SECTIONS
160   /* Read-only sections, merged into text segment: */
161   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}}
162   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}}
163   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0};}}
164   ${CREATE_SHLIB-${INTERP}}
165   
166   ${INITIAL_READONLY_SECTIONS}
168   .init ALIGN(4) : 
169   { 
170     ${RELOCATING+${INIT_START}}
171     KEEP (*(.init))
172     ${RELOCATING+${INIT_END}}
173   } :text =${NOP-0}
175   .text ALIGN(4) :
176   {
177     ${RELOCATING+${TEXT_START_SYMBOLS}}
178     *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
179     /* .gnu.warning sections are handled specially by elf32.em.  */
180     *(.gnu.warning)
181     ${RELOCATING+${OTHER_TEXT_SECTIONS}}
182   } =${NOP-0}
183   
184   ${RELOCATING+${CTOR}}
185   ${RELOCATING+${DTOR}}
186   
187   .fini ALIGN(4) :
188   {
189     ${RELOCATING+${FINI_START}}
190     KEEP (*(.fini))
191     ${RELOCATING+${FINI_END}}
192   } =${NOP-0}
193   
194   ${RELOCATING+PROVIDE (__etext = .);}
195   ${RELOCATING+PROVIDE (_etext = .);}
196   ${RELOCATING+PROVIDE (etext = .);}
197   
198   ${WRITABLE_RODATA-${RODATA}}
199   .rodata1 ALIGN(4) : { *(.rodata1) }
200   
201   ExportTable  ALIGN(4) : { KEEP (*(ExportTable)) }
202   .eh_frame_hdr ALIGN(4) : { *(.eh_frame_hdr) } :text
204   /* Adjust the address for the data segment.  We want to adjust up to
205      the same address within the page on the next page up.  */
206   . = ALIGN(128) + (. & (128 - 1));
207   /* Ensure the __preinit_array_start label is properly aligned.  We
208      could instead move the label definition inside the section, but
209      the linker would then create the section even if it turns out to
210      be empty, which isn't pretty.  */
211   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
212   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
213   .preinit_array   ${RELOCATING-0} : { *(.preinit_array) }
214   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
216   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
217   .init_array   ${RELOCATING-0} : { *(.init_array) }
218   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
220   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
221   .fini_array   ${RELOCATING-0} : { *(.fini_array) }
222   ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
224   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}}
225   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
226   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}
228   .data  ALIGN(4) :
229   {
230     ${RELOCATING+${DATA_START_SYMBOLS}}
231     *(.data${RELOCATING+ .data.* .gnu.linkonce.d.*})
232     ${CONSTRUCTING+SORT(CONSTRUCTORS)}
233   } :data
234   
235   .data1            ALIGN(4) : { *(.data1) } :data
236   .tdata            ALIGN(4) : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } :data
237   .tbss             ALIGN(4) : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } :data
238   .eh_frame         ALIGN(4) : { KEEP (*(.eh_frame)) } :data
239   .gcc_except_table ALIGN(4) : { *(.gcc_except_table) } :data
240   ${WRITABLE_RODATA+${RODATA}}
241   ${OTHER_READWRITE_SECTIONS}
242   ${SDATA}
243   ${OTHER_SDATA_SECTIONS}
244   ${RELOCATING+_edata = .;}
245   ${RELOCATING+PROVIDE (edata = .);}
246   ${RELOCATING+__bss_start = .;}
247   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
248   ${BSS_PLT+${PLT}}
249   .bss  ALIGN(4) :
250   {
251    *(.dynbss)
252    *(.bss${RELOCATING+ .bss.* .gnu.linkonce.b.*})
253    *(COMMON)
254    /* Align here to ensure that the .bss section occupies space up to
255       _end.  Align after .bss to ensure correct alignment even if the
256       .bss section disappears because there are no input sections.  */
257    ${RELOCATING+. = ALIGN(${ALIGNMENT});}
258   } :data
259   ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
260   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
261   ${RELOCATING+${OTHER_END_SYMBOLS}}
262   ${RELOCATING+_end = .;}
263   ${RELOCATING+PROVIDE (end = .);}
264   ${RELOCATING+${DATA_SEGMENT_END}}
266   ${TEXT_DYNAMIC-${DYNAMIC}}
267   ${TEXT_DYNAMIC+${DYNAMIC}}
268   .hash         ${RELOCATING-0} : { *(.hash) } :dynamic :dyn
269   .dynsym       ${RELOCATING-0} : { *(.dynsym) } :dynamic :dyn
270   .dynstr       ${RELOCATING-0} : { *(.dynstr) } :dynamic :dyn
271   ${DATA_PLT-${BSS_PLT-${PLT}}}
272   .got.plt        : { *(.got.plt) } :dynamic :dyn
273   .gnu.version  ${RELOCATING-0} : { *(.gnu.version) }
274   .gnu.version_d ${RELOCATING-0}: { *(.gnu.version_d) }
275   .gnu.version_r ${RELOCATING-0}: { *(.gnu.version_r) }
277 if [ "x$COMBRELOC" = x ]; then
278   COMBRELOCCAT=cat
279 else
280   COMBRELOCCAT="cat > $COMBRELOC"
282 eval $COMBRELOCCAT <<EOF
283   .rel.init     ${RELOCATING-0} : { *(.rel.init) }
284   .rela.init    ${RELOCATING-0} : { *(.rela.init) }
285   .rel.text     ${RELOCATING-0} : { *(.rel.text${RELOCATING+ .rel.text.* .rel.gnu.linkonce.t.*}) }
286   .rela.text    ${RELOCATING-0} : { *(.rela.text${RELOCATING+ .rela.text.* .rela.gnu.linkonce.t.*}) }
287   .rel.fini     ${RELOCATING-0} : { *(.rel.fini) }
288   .rela.fini    ${RELOCATING-0} : { *(.rela.fini) }
289   .rel.rodata   ${RELOCATING-0} : { *(.rel.rodata${RELOCATING+ .rel.rodata.* .rel.gnu.linkonce.r.*}) }
290   .rela.rodata  ${RELOCATING-0} : { *(.rela.rodata${RELOCATING+ .rela.rodata.* .rela.gnu.linkonce.r.*}) }
291   ${OTHER_READONLY_RELOC_SECTIONS}
292   .rel.data     ${RELOCATING-0} : { *(.rel.data${RELOCATING+ .rel.data.* .rel.gnu.linkonce.d.*}) }
293   .rela.data    ${RELOCATING-0} : { *(.rela.data${RELOCATING+ .rela.data.* .rela.gnu.linkonce.d.*}) }
294   .rel.tdata    ${RELOCATING-0} : { *(.rel.tdata${RELOCATING+ .rel.tdata.* .rel.gnu.linkonce.td.*}) }
295   .rela.tdata   ${RELOCATING-0} : { *(.rela.tdata${RELOCATING+ .rela.tdata.* .rela.gnu.linkonce.td.*}) }
296   .rel.tbss     ${RELOCATING-0} : { *(.rel.tbss${RELOCATING+ .rel.tbss.* .rel.gnu.linkonce.tb.*}) }
297   .rela.tbss    ${RELOCATING-0} : { *(.rela.tbss${RELOCATING+ .rela.tbss.* .rela.gnu.linkonce.tb.*}) }
298   .rel.ctors    ${RELOCATING-0} : { *(.rel.ctors) }
299   .rela.ctors   ${RELOCATING-0} : { *(.rela.ctors) }
300   .rel.dtors    ${RELOCATING-0} : { *(.rel.dtors) }
301   .rela.dtors   ${RELOCATING-0} : { *(.rela.dtors) }
302   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
303   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
304   ${OTHER_GOT_RELOC_SECTIONS}
305   .rel.bss      ${RELOCATING-0} : { *(.rel.bss${RELOCATING+ .rel.bss.* .rel.gnu.linkonce.b.*}) }
306   .rela.bss     ${RELOCATING-0} : { *(.rela.bss${RELOCATING+ .rela.bss.* .rela.gnu.linkonce.b.*}) }
308 if [ -n "$COMBRELOC" ]; then
309 cat <<EOF
310   .rel.dyn      ${RELOCATING-0} :
311     {
313 sed -e '/^[     ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rela\./d;s/^.*: { *\(.*\)}$/      \1/' $COMBRELOC
314 cat <<EOF
315     }
316   .rela.dyn     ${RELOCATING-0} :
317     {
319 sed -e '/^[     ]*[{}][         ]*$/d;/:[       ]*$/d;/\.rel\./d;s/^.*: { *\(.*\)}/      \1/' $COMBRELOC
320 cat <<EOF
321     }
324 cat <<EOF
325   .rel.plt      ${RELOCATING-0} : { *(.rel.plt) }
326   .rela.plt     ${RELOCATING-0} : { *(.rela.plt) }
327   ${OTHER_PLT_RELOC_SECTIONS}
330   /* Stabs debugging sections.  */
331   .stab          0 : { *(.stab) }
332   .stabstr       0 : { *(.stabstr) }
333   .stab.excl     0 : { *(.stab.excl) }
334   .stab.exclstr  0 : { *(.stab.exclstr) }
335   .stab.index    0 : { *(.stab.index) }
336   .stab.indexstr 0 : { *(.stab.indexstr) }
338   .comment       0 : { *(.comment) }
340   /* DWARF debug sections.
341      Symbols in the DWARF debugging sections are relative to the beginning
342      of the section so we begin them at 0.  */
344   /* DWARF 1 */
345   .debug          0 : { *(.debug) }
346   .line           0 : { *(.line) }
348   /* GNU DWARF 1 extensions */
349   .debug_srcinfo  0 : { *(.debug_srcinfo) }
350   .debug_sfnames  0 : { *(.debug_sfnames) }
352   /* DWARF 1.1 and DWARF 2 */
353   .debug_aranges  0 : { *(.debug_aranges) }
354   .debug_pubnames 0 : { *(.debug_pubnames) }
356   /* DWARF 2 */
357   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
358   .debug_abbrev   0 : { *(.debug_abbrev) }
359   .debug_line     0 : { *(.debug_line) }
360   .debug_frame    0 : { *(.debug_frame) }
361   .debug_str      0 : { *(.debug_str) }
362   .debug_loc      0 : { *(.debug_loc) }
363   .debug_macinfo  0 : { *(.debug_macinfo) }
365   /* SGI/MIPS DWARF 2 extensions */
366   .debug_weaknames 0 : { *(.debug_weaknames) }
367   .debug_funcnames 0 : { *(.debug_funcnames) }
368   .debug_typenames 0 : { *(.debug_typenames) }
369   .debug_varnames  0 : { *(.debug_varnames) }
371   ${STACK_ADDR+${STACK}}
372   ${OTHER_SECTIONS}
373   ${RELOCATING+${OTHER_SYMBOLS}}
374   ${RELOCATING+${STACKNOTE}}