]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/scripttempl/mcorepe.sc
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / scripttempl / mcorepe.sc
1 # Linker script for MCore PE.
2 #
3 # Copyright (C) 2014-2022 Free Software Foundation, Inc.
4 #
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.
8
9 if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
10 RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
11 fi
12
13 # We can't easily and portably get an unquoted $ in a shell
14 # substitution, so we do this instead.
15 # Sorting of the .foo$* sections is required by the definition of
16 # grouped sections in PE.
17 # Sorting of the file names in R_IDATA is required by the
18 # current implementation of dlltool (this could probably be changed to
19 # use grouped sections instead).
20 if test "${RELOCATING}"; then
21 R_TEXT='*(SORT(.text$*))'
22 R_DATA='*(SORT(.data$*))'
23 R_RDATA='*(SORT(.rdata$*))'
24 R_IDATA='
25 SORT(*)(.idata$2)
26 SORT(*)(.idata$3)
27 /* These zeroes mark the end of the import list. */
28 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
29 SORT(*)(.idata$4)
30 SORT(*)(.idata$5)
31 SORT(*)(.idata$6)
32 SORT(*)(.idata$7)'
33 R_CRT='*(SORT(.CRT$*))'
34 R_RSRC='*(SORT(.rsrc$*))'
35 else
36 R_TEXT=
37 R_DATA=
38 R_RDATA=
39 R_IDATA=
40 R_CRT=
41 R_RSRC=
42 fi
43
44 if test "$RELOCATING"; then
45 # Can't use ${RELOCATING+blah "blah" blah} for this,
46 # because bash 2.x will lose the doublequotes.
47 cat <<EOF
48 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
49 "${LITTLE_OUTPUT_FORMAT}")
50 EOF
51 fi
52
53 cat <<EOF
54 /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
55
56 Copying and distribution of this script, with or without modification,
57 are permitted in any medium without royalty provided the copyright
58 notice and this notice are preserved. */
59
60 ${LIB_SEARCH_DIRS}
61
62 ${RELOCATING+ENTRY (_mainCRTStartup)}
63
64 SECTIONS
65 {
66 .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
67 {
68 ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
69 *(.text)
70 ${R_TEXT}
71 ${RELOCATING+ *(.text.*)}
72 *(.glue_7t)
73 *(.glue_7)
74 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
75 LONG (-1); *(.ctors); *(.ctor); LONG (0); }
76 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
77 LONG (-1); *(.dtors); *(.dtor); LONG (0); }
78 ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
79 ${RELOCATING+/* ??? Why is .gcc_exc here? */}
80 ${RELOCATING+ *(.gcc_exc)}
81 ${RELOCATING+ etext = .;}
82 *(.gcc_except_table)
83 }
84
85 /* The Cygwin32 library uses a section to avoid copying certain data
86 on fork. This used to be named ".data$nocopy". The linker used
87 to include this between __data_start__ and __data_end__, but that
88 breaks building the cygwin32 dll. Instead, we name the section
89 ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
90
91 .data ${RELOCATING+BLOCK(__section_alignment__)} :
92 {
93 ${RELOCATING+__data_start__ = . ;}
94 *(.data)
95 *(.data2)
96 ${R_DATA}
97 ${RELOCATING+__data_end__ = . ;}
98 ${RELOCATING+*(.data_cygwin_nocopy)}
99 }
100
101 .bss ${RELOCATING+BLOCK(__section_alignment__)} :
102 {
103 ${RELOCATING+__bss_start__ = . ;}
104 *(.bss)
105 *(COMMON)
106 ${RELOCATING+__bss_end__ = . ;}
107 }
108
109 .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
110 {
111 *(.rdata)
112 ${R_RDATA}
113 *(.eh_frame)
114 }
115
116 .edata ${RELOCATING+BLOCK(__section_alignment__)} :
117 {
118 *(.edata)
119 }
120
121 /DISCARD/ :
122 {
123 *(.debug\$S)
124 *(.debug\$T)
125 *(.debug\$F)
126 *(.drectve)
127 }
128
129 .idata ${RELOCATING+BLOCK(__section_alignment__)} :
130 {
131 /* This cannot currently be handled with grouped sections.
132 See pe.em:sort_sections. */
133 ${R_IDATA}
134 }
135 .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
136 {
137 ${R_CRT}
138 }
139
140 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
141 {
142 /* end is deprecated, don't use it */
143 ${RELOCATING+ end = .;}
144 ${RELOCATING+ _end = .;}
145 ${RELOCATING+ __end__ = .;}
146 }
147
148 .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
149 {
150 *(.reloc)
151 }
152
153 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
154 {
155 *(.rsrc)
156 ${R_RSRC}
157 }
158
159 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
160 {
161 [ .stab ]
162 }
163
164 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
165 {
166 [ .stabstr ]
167 }
168
169 .stack 0x80000 :
170 {
171 PROVIDE(_stack = .);
172 *(.stack)
173 }
174 }
175 EOF