Fix RELOC_FOR_GLOBAL_SYMBOLS macro so that it can cope with user defined symbols...
[binutils-gdb.git] / ld / scripttempl / v850.sc
blob10d1da8b5bb30e7d8c884b28725dc33c76fe30f1
1 # Copyright (C) 2014-2024 Free Software Foundation, Inc.
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.
7 cat << EOF
8 /* Copyright (C) 2014-2024 Free Software Foundation, Inc.
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.  */
14 OUTPUT_FORMAT("elf32-v850", "elf32-v850",
15               "elf32-v850")
16 OUTPUT_ARCH(v850:old-gcc-abi)
17 ${RELOCATING+ENTRY(_start)}
18 SEARCH_DIR(.);
19 ${RELOCATING+EXTERN(__ctbp __ep __gp)};
20 SECTIONS
22   /* This saves a little space in the ELF file, since the zda starts
23      at a higher location that the ELF headers take up.  */
25   .zdata ${ZDATA_START_ADDR} :
26   {
27         *(.zdata)
28         ${RELOCATING+*(.zbss)
29         *(reszdata)
30         *(.zcommon)}
31   }
33   /* This is the read only part of the zero data area.
34      Having it as a separate section prevents its
35      attributes from being inherited by the zdata
36      section.  Specifically it prevents the zdata
37      section from being marked READONLY.  */
39   .rozdata ${ROZDATA_START_ADDR} :
40   {
41         *(.rozdata)
42         ${RELOCATING+*(romzdata)
43         *(romzbss)}
44   }
46   /* Read-only sections, merged into text segment.  */
47   . = ${TEXT_START_ADDR};
48   .interp       : { *(.interp) }
49   .hash         : { *(.hash) }
50   .dynsym       : { *(.dynsym) }
51   .dynstr       : { *(.dynstr) }
52   .rel.text     : { *(.rel.text) }
53   .rela.text    : { *(.rela.text) }
54   .rel.data     : { *(.rel.data) }
55   .rela.data    : { *(.rela.data) }
56   .rel.rodata   : { *(.rel.rodata) }
57   .rela.rodata  : { *(.rela.rodata) }
58   .rel.gcc_except_table : { *(.rel.gcc_except_table) }
59   .rela.gcc_except_table : { *(.rela.gcc_except_table) }
60   .rel.got      : { *(.rel.got) }
61   .rela.got     : { *(.rela.got) }
62   .rel.ctors    : { *(.rel.ctors) }
63   .rela.ctors   : { *(.rela.ctors) }
64   .rel.dtors    : { *(.rel.dtors) }
65   .rela.dtors   : { *(.rela.dtors) }
66   .rel.init     : { *(.rel.init) }
67   .rela.init    : { *(.rela.init) }
68   .rel.fini     : { *(.rel.fini) }
69   .rela.fini    : { *(.rela.fini) }
70   .rel.bss      : { *(.rel.bss) }
71   .rela.bss     : { *(.rela.bss) }
72   .rel.plt      : { *(.rel.plt) }
73   .rela.plt     : { *(.rela.plt) }
74   .init         : { KEEP (*(SORT_NONE(.init))) } =0
75   .plt          : { *(.plt) }
77   .text         :
78   {
79     *(.text)
80     ${RELOCATING+*(.text.*)}
82     /* .gnu.warning sections are handled specially by elf.em.  */
83     *(.gnu.warning)
84     ${RELOCATING+*(.gnu.linkonce.t*)}
85   } =0
87   ${RELOCATING+_etext = .;}
88   ${RELOCATING+PROVIDE (etext = .);}
90    /* This is special code area at the end of the normal text section.
91       It contains a small lookup table at the start followed by the
92       code pointed to by entries in the lookup table.  */
94   .call_table_data ${CALL_TABLE_START_ADDR} :
95   {
96     ${RELOCATING+PROVIDE(__ctbp = .);}
97     *(.call_table_data)
98   } = 0xff   /* Fill gaps with 0xff.  */
100   .call_table_text :
101   {
102     *(.call_table_text)
103   }
105   .fini         : { KEEP (*(SORT_NONE(.fini))) } =0
106   .rodata       : { *(.rodata) ${RELOCATING+*(.rodata.*) *(.gnu.linkonce.r*)} }
107   .rodata1      : { *(.rodata1) }
109   .data         :
110   {
111     *(.data)
112     ${RELOCATING+*(.data.*)
113     *(.gnu.linkonce.d*)}
114     ${CONSTRUCTING+CONSTRUCTORS}
115   }
116   .data1        : { *(.data1) }
117   .ctors        :
118   {
119     ${CONSTRUCTING+___ctors = .;}
120     KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
121     ${RELOCATING+KEEP (*(SORT(.ctors.*)))}
122     KEEP (*crtend(.ctors))
123     ${CONSTRUCTING+___ctors_end = .;}
124   }
125   .dtors        :
126   {
127     ${CONSTRUCTING+___dtors = .;}
128     KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
129     ${RELOCATING+KEEP (*(SORT(.dtors.*)))}
130     KEEP (*crtend.o(.dtors))
131     ${CONSTRUCTING+___dtors_end = .;}
132   }
133   .jcr          :
134   {
135     KEEP (*(.jcr))
136   }
138   .gcc_except_table : { *(.gcc_except_table) }
140   .got          : {${RELOCATING+ *(.got.plt)} *(.got) }
141   .dynamic      : { *(.dynamic) }
143   .tdata ${TDATA_START_ADDR} :
144   {
145         ${RELOCATING+PROVIDE (__ep = .);
146         *(.tbyte)
147         *(.tcommon_byte)}
148         *(.tdata)
149         ${RELOCATING+*(.tbss)
150         *(.tcommon)}
151   }
153   /* We want the small data sections together, so single-instruction offsets
154      can access them all, and initialized data all before uninitialized, so
155      we can shorten the on-disk segment size.  */
157   .sdata ${SDATA_START_ADDR} :
158   {
159         ${RELOCATING+PROVIDE (__gp = . + 0x8000);}
160         *(.sdata)
161    }
163   /* See comment about .rozdata. */
164   .rosdata ${ROSDATA_START_ADDR} :
165   {
166         *(.rosdata)
167   }
169   /* We place the .sbss data section AFTER the .rosdata section, so that
170      it can directly precede the .bss section.  This allows runtime startup
171      code to initialise all the zero-data sections by simply taking the
172      value of '_edata' and zeroing until it reaches '_end'.  */
174   .sbss :
175   {
176         ${RELOCATING+__sbss_start = .;}
177         *(.sbss)
178         ${RELOCATING+*(.scommon)}
179   }
181   ${RELOCATING+_edata  = DEFINED (__sbss_start) ? __sbss_start : . ;}
182   ${RELOCATING+PROVIDE (edata = _edata);}
184   .bss       :
185   {
186         ${RELOCATING+__bss_start = DEFINED (__sbss_start) ? __sbss_start : . ;}
187         ${RELOCATING+__real_bss_start = . ;}
188         ${RELOCATING+*(.dynbss)}
189         *(.bss)
190         ${RELOCATING+*(COMMON)}
191   }
193   ${RELOCATING+_end = . ;}
194   ${RELOCATING+PROVIDE (end = .);}
195   ${RELOCATING+PROVIDE (_heap_start = .);}
197   .note.renesas 0 : { KEEP(*(.note.renesas)) }
201 source_sh $srcdir/scripttempl/misc-sections.sc
202 source_sh $srcdir/scripttempl/DWARF.sc
204 cat <<EOF
205   /* User stack.  */
206   .stack 0x200000       :
207   {
208         ${RELOCATING+__stack = .;}
209         *(.stack)
210   }