Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # |
2 | # Unusual variables checked by this code: | |
3 | # NOP - two 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 and .sdata. | |
20 | # OTHER_BSS_SYMBOLS - symbols that appear at the start of the | |
21 | # .bss section besides __bss_start. | |
22 | # DATA_PLT - .plt should be in data segment, not text segment. | |
23 | # TEXT_DYNAMIC - .dynamic in text segment, not data segment. | |
24 | # EMBEDDED - whether this is for an embedded system. | |
25 | # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set | |
26 | # start address of shared library. | |
27 | # INPUT_FILES - INPUT command of files to always include | |
a8e53fb0 | 28 | # WRITABLE_RODATA - if set, the .rodata section should be writable |
252b5132 RH |
29 | # |
30 | # When adding sections, do note that the names of some sections are used | |
31 | # when specifying the start address of the next. | |
32 | # | |
33 | ||
34 | test -z "$ENTRY" && ENTRY=_start | |
35 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
36 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
37 | if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi | |
38 | test -z "${ELFSIZE}" && ELFSIZE=32 | |
39 | test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8" | |
40 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
41 | INTERP=".interp ${RELOCATING-0} : { *(.interp) }" | |
42 | PLT=".plt ${RELOCATING-0} : { *(.plt) }" | |
43 | DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" | |
a8e53fb0 | 44 | RODATA=".rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r*)} }" |
252b5132 RH |
45 | CTOR=".ctors ${CONSTRUCTING-0} : |
46 | { | |
47 | ${CONSTRUCTING+${CTOR_START}} | |
48 | /* gcc uses crtbegin.o to find the start of | |
49 | the constructors, so we make sure it is | |
50 | first. Because this is a wildcard, it | |
51 | doesn't matter if the user does not | |
52 | actually link against crtbegin.o; the | |
53 | linker won't look for a file to match a | |
54 | wildcard. The wildcard also means that it | |
55 | doesn't matter which directory crtbegin.o | |
56 | is in. */ | |
57 | ||
58 | KEEP (*crtbegin.o(.ctors)) | |
59 | ||
60 | /* We don't want to include the .ctor section from | |
61 | from the crtend.o file until after the sorted ctors. | |
62 | The .ctor section from the crtend file contains the | |
63 | end of ctors marker and it must be last */ | |
64 | ||
65 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) | |
66 | KEEP (*(SORT(.ctors.*))) | |
67 | KEEP (*(.ctors)) | |
68 | ${CONSTRUCTING+${CTOR_END}} | |
69 | }" | |
70 | ||
71 | DTOR=" .dtors ${CONSTRUCTING-0} : | |
72 | { | |
73 | ${CONSTRUCTING+${DTOR_START}} | |
74 | KEEP (*crtbegin.o(.dtors)) | |
75 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) | |
76 | KEEP (*(SORT(.dtors.*))) | |
77 | KEEP (*(.dtors)) | |
78 | ${CONSTRUCTING+${DTOR_END}} | |
79 | }" | |
80 | ||
81 | # if this is for an embedded system, don't add SIZEOF_HEADERS. | |
82 | if [ -z "$EMBEDDED" ]; then | |
83 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" | |
84 | else | |
85 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" | |
86 | fi | |
87 | ||
88 | cat <<EOF | |
89 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", | |
90 | "${LITTLE_OUTPUT_FORMAT}") | |
91 | OUTPUT_ARCH(${OUTPUT_ARCH}) | |
92 | ENTRY(${ENTRY}) | |
93 | ||
94 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
95 | ${RELOCATING+/* Do we need any of these for elf? | |
96 | __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} | |
97 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} | |
98 | ${RELOCATING+${INPUT_FILES}} | |
99 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables | |
100 | if gld -r is used and the intermediate file has sections starting | |
101 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
102 | bug. But for now assigning the zero vmas works. */} | |
103 | ||
104 | SECTIONS | |
105 | { | |
106 | /* Read-only sections, merged into text segment: */ | |
107 | ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} | |
108 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} | |
109 | ${CREATE_SHLIB-${INTERP}} | |
110 | ${INITIAL_READONLY_SECTIONS} | |
111 | ${TEXT_DYNAMIC+${DYNAMIC}} | |
112 | .hash ${RELOCATING-0} : { *(.hash) } | |
113 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
114 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
115 | .gnu.version ${RELOCATING-0} : { *(.gnu.version) } | |
116 | .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } | |
117 | .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } | |
9e4141bc RH |
118 | |
119 | .rel.init ${RELOCATING-0} : { *(.rel.init) } | |
120 | .rela.init ${RELOCATING-0} : { *(.rela.init) } | |
252b5132 RH |
121 | .rel.text ${RELOCATING-0} : |
122 | { | |
123 | *(.rel.text) | |
124 | ${RELOCATING+*(.rel.text.*)} | |
125 | ${RELOCATING+*(.rel.gnu.linkonce.t*)} | |
126 | } | |
127 | .rela.text ${RELOCATING-0} : | |
128 | { | |
129 | *(.rela.text) | |
130 | ${RELOCATING+*(.rela.text.*)} | |
131 | ${RELOCATING+*(.rela.gnu.linkonce.t*)} | |
132 | } | |
9e4141bc RH |
133 | .rel.fini ${RELOCATING-0} : { *(.rel.fini) } |
134 | .rela.fini ${RELOCATING-0} : { *(.rela.fini) } | |
252b5132 RH |
135 | .rel.rodata ${RELOCATING-0} : |
136 | { | |
137 | *(.rel.rodata) | |
138 | ${RELOCATING+*(.rel.rodata.*)} | |
139 | ${RELOCATING+*(.rel.gnu.linkonce.r*)} | |
140 | } | |
141 | .rela.rodata ${RELOCATING-0} : | |
142 | { | |
143 | *(.rela.rodata) | |
144 | ${RELOCATING+*(.rela.rodata.*)} | |
145 | ${RELOCATING+*(.rela.gnu.linkonce.r*)} | |
146 | } | |
9e4141bc RH |
147 | ${OTHER_READONLY_RELOC_SECTIONS} |
148 | .rel.data ${RELOCATING-0} : | |
149 | { | |
150 | *(.rel.data) | |
151 | ${RELOCATING+*(.rel.data.*)} | |
152 | ${RELOCATING+*(.rel.gnu.linkonce.d*)} | |
153 | } | |
154 | .rela.data ${RELOCATING-0} : | |
155 | { | |
156 | *(.rela.data) | |
157 | ${RELOCATING+*(.rela.data.*)} | |
158 | ${RELOCATING+*(.rela.gnu.linkonce.d*)} | |
159 | } | |
252b5132 RH |
160 | .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } |
161 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
162 | .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } | |
163 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
9e4141bc RH |
164 | .rel.got ${RELOCATING-0} : { *(.rel.got) } |
165 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
166 | ${OTHER_GOT_RELOC_SECTIONS} | |
252b5132 RH |
167 | .rel.bss ${RELOCATING-0} : { *(.rel.bss) } |
168 | .rela.bss ${RELOCATING-0} : { *(.rela.bss) } | |
169 | .rel.plt ${RELOCATING-0} : { *(.rel.plt) } | |
170 | .rela.plt ${RELOCATING-0} : { *(.rela.plt) } | |
9e4141bc | 171 | |
252b5132 RH |
172 | .init ${RELOCATING-0} : { KEEP (*(.init)) } =${NOP-0} |
173 | ${DATA_PLT-${PLT}} | |
174 | .text ${RELOCATING-0} : | |
175 | { | |
176 | ${RELOCATING+${TEXT_START_SYMBOLS}} | |
177 | *(.text) | |
178 | ${RELOCATING+*(.text.*)} | |
179 | *(.stub) | |
180 | /* .gnu.warning sections are handled specially by elf32.em. */ | |
181 | *(.gnu.warning) | |
182 | ${RELOCATING+*(.gnu.linkonce.t*)} | |
183 | ${RELOCATING+${OTHER_TEXT_SECTIONS}} | |
184 | } =${NOP-0} | |
185 | ${RELOCATING+_etext = .;} | |
186 | ${RELOCATING+PROVIDE (etext = .);} | |
187 | .fini ${RELOCATING-0} : { KEEP (*(.fini)) } =${NOP-0} | |
a8e53fb0 | 188 | ${WRITABLE_RODATA-${RODATA}} |
252b5132 RH |
189 | .rodata1 ${RELOCATING-0} : { *(.rodata1) } |
190 | ${RELOCATING+${OTHER_READONLY_SECTIONS}} | |
191 | ||
192 | /* Adjust the address for the data segment. We want to adjust up to | |
193 | the same address within the page on the next page up. */ | |
194 | ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} | |
195 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} | |
196 | ||
197 | .data ${RELOCATING-0} : | |
198 | { | |
199 | ${RELOCATING+${DATA_START_SYMBOLS}} | |
200 | *(.data) | |
201 | ${RELOCATING+*(.data.*)} | |
202 | ${RELOCATING+*(.gnu.linkonce.d*)} | |
203 | ${CONSTRUCTING+SORT(CONSTRUCTORS)} | |
204 | } | |
205 | .data1 ${RELOCATING-0} : { *(.data1) } | |
206 | .eh_frame : { *(.eh_frame) } | |
207 | .gcc_except_table : { *(.gcc_except_table) } | |
a8e53fb0 | 208 | ${WRITABLE_RODATA+${RODATA}} |
252b5132 RH |
209 | ${RELOCATING+${OTHER_READWRITE_SECTIONS}} |
210 | ${RELOCATING+${CTOR}} | |
211 | ${RELOCATING+${DTOR}} | |
212 | ${DATA_PLT+${PLT}} | |
213 | ${RELOCATING+${OTHER_GOT_SYMBOLS}} | |
214 | .got ${RELOCATING-0} : { *(.got.plt) *(.got) } | |
215 | ${TEXT_DYNAMIC-${DYNAMIC}} | |
216 | /* We want the small data sections together, so single-instruction offsets | |
217 | can access them all, and initialized data all before uninitialized, so | |
218 | we can shorten the on-disk segment size. */ | |
219 | .sdata ${RELOCATING-0} : { *(.sdata) *(.sdata.*) } | |
220 | ${RELOCATING+${OTHER_GOT_SECTIONS}} | |
9e4141bc | 221 | ${RELOCATING+_edata = .;} |
252b5132 RH |
222 | ${RELOCATING+PROVIDE (edata = .);} |
223 | ${RELOCATING+__bss_start = .;} | |
224 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} | |
225 | .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } | |
226 | .bss ${RELOCATING-0} : | |
227 | { | |
228 | *(.dynbss) | |
229 | *(.bss) | |
230 | *(COMMON) | |
231 | /* Align here to ensure that the .bss section occupies space up to | |
232 | _end. Align after .bss to ensure correct alignment even if the | |
233 | .bss section disappears because there are no input sections. */ | |
234 | ${RELOCATING+. = ALIGN(${ALIGNMENT});} | |
235 | } | |
236 | ${RELOCATING+. = ALIGN(${ALIGNMENT});} | |
9e4141bc | 237 | ${RELOCATING+_end = .;} |
252b5132 RH |
238 | ${RELOCATING+${OTHER_BSS_END_SYMBOLS}} |
239 | ${RELOCATING+PROVIDE (end = .);} | |
240 | ||
241 | /* Stabs debugging sections. */ | |
242 | .stab 0 : { *(.stab) } | |
243 | .stabstr 0 : { *(.stabstr) } | |
244 | .stab.excl 0 : { *(.stab.excl) } | |
245 | .stab.exclstr 0 : { *(.stab.exclstr) } | |
246 | .stab.index 0 : { *(.stab.index) } | |
247 | .stab.indexstr 0 : { *(.stab.indexstr) } | |
248 | ||
249 | .comment 0 : { *(.comment) } | |
250 | ||
251 | /* DWARF debug sections. | |
252 | Symbols in the DWARF debugging sections are relative to the beginning | |
253 | of the section so we begin them at 0. */ | |
254 | ||
255 | /* DWARF 1 */ | |
256 | .debug 0 : { *(.debug) } | |
257 | .line 0 : { *(.line) } | |
258 | ||
259 | /* GNU DWARF 1 extensions */ | |
260 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | |
261 | .debug_sfnames 0 : { *(.debug_sfnames) } | |
262 | ||
263 | /* DWARF 1.1 and DWARF 2 */ | |
264 | .debug_aranges 0 : { *(.debug_aranges) } | |
265 | .debug_pubnames 0 : { *(.debug_pubnames) } | |
266 | ||
267 | /* DWARF 2 */ | |
268 | .debug_info 0 : { *(.debug_info) } | |
269 | .debug_abbrev 0 : { *(.debug_abbrev) } | |
270 | .debug_line 0 : { *(.debug_line) } | |
271 | .debug_frame 0 : { *(.debug_frame) } | |
272 | .debug_str 0 : { *(.debug_str) } | |
273 | .debug_loc 0 : { *(.debug_loc) } | |
274 | .debug_macinfo 0 : { *(.debug_macinfo) } | |
275 | ||
276 | /* SGI/MIPS DWARF 2 extensions */ | |
277 | .debug_weaknames 0 : { *(.debug_weaknames) } | |
278 | .debug_funcnames 0 : { *(.debug_funcnames) } | |
279 | .debug_typenames 0 : { *(.debug_typenames) } | |
280 | .debug_varnames 0 : { *(.debug_varnames) } | |
281 | ||
282 | ${RELOCATING+${OTHER_RELOCATING_SECTIONS}} | |
283 | ||
284 | /* These must appear regardless of ${RELOCATING}. */ | |
285 | ${OTHER_SECTIONS} | |
286 | } | |
287 | EOF |