2 # Unusual variables checked by this code:
3 # NOP - two byte opcode for no-op (defaults to 0)
4 # INITIAL_READONLY_SECTIONS - at start of text segment
5 # OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
6 # (e.g., .PARISC.milli)
7 # OTHER_TEXT_SECTIONS - these get put in .text when relocating
8 # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
9 # (e.g., .PARISC.global)
10 # OTHER_BSS_SECTIONS - other than .bss .sbss ...
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
16 # DATA_START_SYMBOLS - symbols that appear at the start of the
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 # INPUT_FILES - INPUT command of files to always include
23 # INIT_START, INIT_END - statements just before and just after
24 # combination of .init sections.
25 # FINI_START, FINI_END - statements just before and just after
26 # combination of .fini sections.
28 # When adding sections, do note that the names of some sections are used
29 # when specifying the start address of the next.
32 # Many sections come in three flavours. There is the 'real' section,
33 # like ".data". Then there are the per-procedure or per-variable
34 # sections, generated by -ffunction-sections and -fdata-sections in GCC,
35 # and useful for --gc-sections, which for a variable "foo" might be
36 # ".data.foo". Then there are the linkonce sections, for which the linker
37 # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
38 # The exact correspondences are:
40 # Section Linkonce section
41 # .text .gnu.linkonce.t.foo
42 # .rodata .gnu.linkonce.r.foo
43 # .data .gnu.linkonce.d.foo
44 # .bss .gnu.linkonce.b.foo
45 # .sdata .gnu.linkonce.s.foo
46 # .sbss .gnu.linkonce.sb.foo
47 # .sdata2 .gnu.linkonce.s2.foo
48 # .sbss2 .gnu.linkonce.sb2.foo
50 # Each of these can also have corresponding .rel.* and .rela.* sections.
52 test -z "$ENTRY" && ENTRY=_start
53 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
54 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
55 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
56 test -z "${ELFSIZE}" && ELFSIZE=32
57 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
58 CTOR=".ctors ${CONSTRUCTING-0} :
60 ${CONSTRUCTING+${CTOR_START}}
61 /* gcc uses crtbegin.o to find the start of
62 the constructors, so we make sure it is
63 first. Because this is a wildcard, it
64 doesn't matter if the user does not
65 actually link against crtbegin.o; the
66 linker won't look for a file to match a
67 wildcard. The wildcard also means that it
68 doesn't matter which directory crtbegin.o
71 KEEP (*crtbegin*.o(.ctors))
73 /* We don't want to include the .ctor section from
74 from the crtend.o file until after the sorted ctors.
75 The .ctor section from the crtend file contains the
76 end of ctors marker and it must be last */
78 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
79 KEEP (*(SORT(.ctors.*)))
81 ${CONSTRUCTING+${CTOR_END}}
84 DTOR=" .dtors ${CONSTRUCTING-0} :
86 ${CONSTRUCTING+${DTOR_START}}
87 KEEP (*crtbegin*.o(.dtors))
88 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
89 KEEP (*(SORT(.dtors.*)))
91 ${CONSTRUCTING+${DTOR_END}}
95 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
96 "${LITTLE_OUTPUT_FORMAT}")
97 OUTPUT_ARCH(${OUTPUT_ARCH})
100 ${RELOCATING+${LIB_SEARCH_DIRS}}
101 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
102 ${RELOCATING+${INPUT_FILES}}
103 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
104 if gld -r is used and the intermediate file has sections starting
105 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
106 bug. But for now assigning the zero vmas works. */}
108 /* There are two memory regions we care about, one from 0 through 0x7F00
109 that is RAM and one from 0x8000 up which is ROM. */
112 RAM (w) : ORIGIN = 0, LENGTH = 0x7F00
113 ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000
118 .data ${RELOCATING-0} :
120 ${RELOCATING+__rdata = .;}
121 ${RELOCATING+__data = .;}
122 ${RELOCATING+${DATA_START_SYMBOLS}}
124 ${RELOCATING+*(.data.*)}
125 ${RELOCATING+*(.gnu.linkonce.d.*)}
126 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
128 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
129 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
130 ${RELOCATING+${OTHER_GOT_SECTIONS}}
131 ${RELOCATING+_edata = .;}
132 ${RELOCATING+PROVIDE (edata = .);}
133 ${RELOCATING+__bss_start = .;}
134 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
135 .bss ${RELOCATING-0} :
139 ${RELOCATING+*(.bss.*)}
140 ${RELOCATING+*(.gnu.linkonce.b.*)}
142 /* Align here to ensure that the .bss section occupies space up to
143 _end. Align after .bss to ensure correct alignment even if the
144 .bss section disappears because there are no input sections. */
145 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
147 ${RELOCATING+${OTHER_BSS_SECTIONS}}
148 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
149 ${RELOCATING+_end = .;}
150 ${RELOCATING+__stack = .;}
151 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
152 ${RELOCATING+PROVIDE (end = .);}
154 /* Read-only sections in ROM. */
155 .int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM}
157 .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${RELOCATING+> ROM}
158 ${RELOCATING+${CTOR}}
159 ${RELOCATING+${DTOR}}
160 .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ROM}
161 .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ROM}
162 .gcc_except_table : { *(.gcc_except_table) } ${RELOCATING+> ROM}
163 .plt : { *(.plt) } ${RELOCATING+> ROM}
165 .text ${RELOCATING-0} :
167 ${RELOCATING+${TEXT_START_SYMBOLS}}
169 ${RELOCATING+*(.text.*)}
171 /* .gnu.warning sections are handled specially by elf32.em. */
173 ${RELOCATING+*(.gnu.linkonce.t.*)}
174 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
175 } ${RELOCATING+> ROM =${NOP-0}}
176 .init ${RELOCATING-0} :
178 ${RELOCATING+${INIT_START}}
180 ${RELOCATING+${INIT_END}}
181 } ${RELOCATING+> ROM =${NOP-0}}
182 .fini ${RELOCATING-0} :
184 ${RELOCATING+${FINI_START}}
186 ${RELOCATING+${FINI_END}}
187 } ${RELOCATING+> ROM =${NOP-0}}
188 ${RELOCATING+PROVIDE (__etext = .);}
189 ${RELOCATING+PROVIDE (_etext = .);}
190 ${RELOCATING+PROVIDE (etext = .);}
191 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
194 /* Stabs debugging sections. */
195 .stab 0 : { *(.stab) }
196 .stabstr 0 : { *(.stabstr) }
197 .stab.excl 0 : { *(.stab.excl) }
198 .stab.exclstr 0 : { *(.stab.exclstr) }
199 .stab.index 0 : { *(.stab.index) }
200 .stab.indexstr 0 : { *(.stab.indexstr) }
202 .comment 0 : { *(.comment) }
204 /* DWARF debug sections.
205 Symbols in the DWARF debugging sections are relative to the beginning
206 of the section so we begin them at 0. */
209 .debug 0 : { *(.debug) }
210 .line 0 : { *(.line) }
212 /* GNU DWARF 1 extensions */
213 .debug_srcinfo 0 : { *(.debug_srcinfo) }
214 .debug_sfnames 0 : { *(.debug_sfnames) }
216 /* DWARF 1.1 and DWARF 2 */
217 .debug_aranges 0 : { *(.debug_aranges) }
218 .debug_pubnames 0 : { *(.debug_pubnames) }
221 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
222 .debug_abbrev 0 : { *(.debug_abbrev) }
223 .debug_line 0 : { *(.debug_line) }
224 .debug_frame 0 : { *(.debug_frame) }
225 .debug_str 0 : { *(.debug_str) }
226 .debug_loc 0 : { *(.debug_loc) }
227 .debug_macinfo 0 : { *(.debug_macinfo) }
229 /* SGI/MIPS DWARF 2 extensions */
230 .debug_weaknames 0 : { *(.debug_weaknames) }
231 .debug_funcnames 0 : { *(.debug_funcnames) }
232 .debug_typenames 0 : { *(.debug_typenames) }
233 .debug_varnames 0 : { *(.debug_varnames) }
235 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
237 /* These must appear regardless of ${RELOCATING}. */