Fix RELOC_FOR_GLOBAL_SYMBOLS macro so that it can cope with user defined symbols...
[binutils-gdb.git] / ld / scripttempl / elfmicroblaze.sc
blob88abe4f10ba533c99e1e60e970d493bd99e01643
1 # Adapted from mips.sc
3 # Copyright (C) 2014-2024 Free Software Foundation, Inc.
5 # Copying and distribution of this file, with or without modification,
6 # are permitted in any medium without royalty provided the copyright
7 # notice and this notice are preserved.
9 # These variables may be overridden by the emulation file.  The
10 # defaults are appropriate for a DECstation running Ultrix.
12 test -z "$ENTRY" && ENTRY=_start
14 #test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x0"
16 CTOR=".ctors ${CONSTRUCTING-0} :
17   {
18     ${CONSTRUCTING+${CTOR_START}}
19     /* gcc uses crtbegin.o to find the start of
20        the constructors, so we make sure it is
21        first.  Because this is a wildcard, it
22        doesn't matter if the user does not
23        actually link against crtbegin.o; the
24        linker won't look for a file to match a
25        wildcard.  The wildcard also means that it
26        doesn't matter which directory crtbegin.o
27        is in.  */
29     KEEP (*crtbegin.o(.ctors))
31     /* We don't want to include the .ctor section from
32        from the crtend.o file until after the sorted ctors.
33        The .ctor section from the crtend file contains the
34        end of ctors marker and it must be last */
36     KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
37     KEEP (*(SORT(.ctors.*)))
38     KEEP (*(.ctors))
39     ${CONSTRUCTING+${CTOR_END}}
40   }"
42 DTOR=" .dtors       ${CONSTRUCTING-0} :
43   {
44     ${CONSTRUCTING+${DTOR_START}}
45     KEEP (*crtbegin.o(.dtors))
46     KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
47     KEEP (*(SORT(.dtors.*)))
48     KEEP (*(.dtors))
49     ${CONSTRUCTING+${DTOR_END}}
50   }"
52 cat <<EOF
53 /* Copyright (C) 2014-2024 Free Software Foundation, Inc.
55    Copying and distribution of this script, with or without modification,
56    are permitted in any medium without royalty provided the copyright
57    notice and this notice are preserved.  */
59 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
60               "${LITTLE_OUTPUT_FORMAT}")
61 /*${LIB_SEARCH_DIRS}*/
62 ${RELOCATING+${LIB_SEARCH_DIRS}}
64 ${RELOCATING+ENTRY (${ENTRY})}
66 ${RELOCATING+_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50;
67 _HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0;
68 _STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;}
70 SECTIONS
72   .vectors.reset 0x0 : { KEEP (*(.vectors.reset)) } = 0
73   .vectors.sw_exception 0x8 : { KEEP (*(.vectors.sw_exception)) } = 0
74   .vectors.interrupt 0x10 : { KEEP (*(.vectors.interrupt)) } = 0
75   .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0
76   .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0
78   ${RELOCATING+. = _TEXT_START_ADDR;}
80   ${RELOCATING+ _ftext  =  .;}
81   .text : {
82     *(.text)
83     ${RELOCATING+*(.text.*)}
84     ${RELOCATING+*(.gnu.linkonce.t.*)}
85   }
86   ${RELOCATING+ _etext  =  .;}
88   .init : { KEEP (*(SORT_NONE(.init)))  } =0
89   .fini : { KEEP (*(SORT_NONE(.fini)))  } =0
91   ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);}
92   ${RELOCATING+PROVIDE (___CTOR_LIST__ = .);}
93   ${RELOCATING+${CTOR}}
94   ${RELOCATING+PROVIDE (__CTOR_END__ = .);}
95   ${RELOCATING+PROVIDE (___CTOR_END__ = .);}
97   ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);}
98   ${RELOCATING+PROVIDE (___DTOR_LIST__ = .);}
99   ${RELOCATING+${DTOR}}
100   ${RELOCATING+PROVIDE (__DTOR_END__ = .);}
101   ${RELOCATING+PROVIDE (___DTOR_END__ = .);}
103   ${RELOCATING+ . = ALIGN(4);}
104    ${RELOCATING+ _frodata = . ;}
105   .rodata : {
106     *(.rodata)
107     ${RELOCATING+*(.rodata.*)}
108     ${RELOCATING+*(.gnu.linkonce.r.*)}
109     ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */
110   }
111   ${RELOCATING+ _erodata = .;}
113   /* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */
114   /* Note that .sdata2 and .sbss2 must be contiguous */
115   ${RELOCATING+. = ALIGN(8);}
116   ${RELOCATING+ _ssrw = .;}
117   .sdata2 : {
118     *(.sdata2)
119     ${RELOCATING+*(.sdata2.*)}
120     ${RELOCATING+*(.gnu.linkonce.s2.*)}
121   }
122   ${RELOCATING+. = ALIGN(4);}
123   .sbss2 : {
124     ${RELOCATING+PROVIDE (__sbss2_start = .);}
125     *(.sbss2)
126     ${RELOCATING+*(.sbss2.*)}
127     ${RELOCATING+*(.gnu.linkonce.sb2.*)}
128     ${RELOCATING+PROVIDE (__sbss2_end = .);}
129   }
130   ${RELOCATING+. = ALIGN(8);}
131   ${RELOCATING+ _essrw = .;}
132   ${RELOCATING+ _ssrw_size = _essrw - _ssrw;}
133   ${RELOCATING+ PROVIDE (_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 ));}
135   ${RELOCATING+ . = ALIGN(4);}
136   ${RELOCATING+ _fdata = .;}
137   .data : {
138     *(.data)
139     ${RELOCATING+*(.data.*)}
140     ${RELOCATING+*(.gnu.linkonce.d.*)}
141     ${CONSTRUCTING+CONSTRUCTORS;} /* Is this needed? */
142   }
143   ${RELOCATING+ _edata = . ;}
145    /* Added to handle pic code */
146   .got : {
147     *(.got)
148   }
150   .got1 : {
151     *(.got1)
152   }
154   .got2 : {
155     *(.got2)
156   }
158   /* Added by Sathya to handle C++ exceptions */
159   .eh_frame : {
160     *(.eh_frame)
161   }
163   .jcr : {
164     *(.jcr)
165   }
167   .gcc_except_table : {
168     *(.gcc_except_table)
169   }
171   /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */
172   /* Note that .sdata and .sbss must be contiguous */
173   ${RELOCATING+. = ALIGN(8);}
174   ${RELOCATING+ _ssro = .;}
175   .sdata : {
176     *(.sdata)
177     ${RELOCATING+*(.sdata.*)}
178     ${RELOCATING+*(.gnu.linkonce.s.*)}
179   }
180   ${RELOCATING+. = ALIGN(4);}
181   .sbss : {
182     ${RELOCATING+PROVIDE (__sbss_start = .);}
183     *(.sbss)
184     ${RELOCATING+*(.sbss.*)}
185     ${RELOCATING+*(.gnu.linkonce.sb.*)}
186     ${RELOCATING+PROVIDE (__sbss_end = .);}
187   }
188   ${RELOCATING+. = ALIGN(8);}
189   ${RELOCATING+ _essro = .;}
190   ${RELOCATING+ _ssro_size = _essro - _ssro;}
191   ${RELOCATING+PROVIDE (_SDA_BASE_ = _ssro + (_ssro_size / 2 ));}
193   ${RELOCATING+ . = ALIGN(4);}
194   ${RELOCATING+ _fbss = .;}
195   .bss : {
196     ${RELOCATING+PROVIDE (__bss_start = .);}
197     *(.bss)
198     ${RELOCATING+*(.bss.*)}
199     ${RELOCATING+*(.gnu.linkonce.b.*)}
200     ${RELOCATING+*(COMMON)}
201     ${RELOCATING+. = ALIGN(. != 0 ? 4 : 1);}
203     ${RELOCATING+PROVIDE (__bss_end = .);}
204   }
206   ${RELOCATING+ . = ALIGN(4);}
208   .heap : {
209     ${RELOCATING+ _heap = .;}
210     ${RELOCATING+ _heap_start = .;}
211     ${RELOCATING+ . += _HEAP_SIZE;}
212     ${RELOCATING+ _heap_end = .;}
213   }
215   ${RELOCATING+ . = ALIGN(4);}
217   .stack : {
218     ${RELOCATING+ _stack_end = .;}
219     ${RELOCATING+ . += _STACK_SIZE;}
220     ${RELOCATING+ . = ALIGN(. != 0 ? 8 : 1);}
221     ${RELOCATING+ _stack = .;}
222     ${RELOCATING+ _end = .;}
223   }
225   .tdata : {
226     *(.tdata)
227     ${RELOCATING+*(.tdata.*)}
228     ${RELOCATING+*(.gnu.linkonce.td.*)}
229   }
230   .tbss : {
231     *(.tbss)
232     ${RELOCATING+*(.tbss.*)}
233     ${RELOCATING+*(.gnu.linkonce.tb.*)}
234   }
237 source_sh $srcdir/scripttempl/misc-sections.sc
238 source_sh $srcdir/scripttempl/DWARF.sc
240 cat <<EOF