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_SECTIONS - at the end
11 # EXECUTABLE_SYMBOLS - symbols that must be defined for an
12 # executable (e.g., _DYNAMIC_LINK)
13 # TEXT_START_SYMBOLS - symbols that appear at the start of the
15 # DATA_START_SYMBOLS - symbols that appear at the start of the
17 # OTHER_GOT_SYMBOLS - symbols defined just before .got.
18 # OTHER_GOT_SECTIONS - sections just after .got and .sdata.
19 # OTHER_BSS_SYMBOLS - symbols that appear at the start of the
20 # .bss section besides __bss_start.
21 # INPUT_FILES - INPUT command of files to always include
22 # INIT_START, INIT_END - statements just before and just after
23 # combination of .init sections.
24 # FINI_START, FINI_END - statements just before and just after
25 # combination of .fini sections.
27 # When adding sections, do note that the names of some sections are used
28 # when specifying the start address of the next.
31 # Many sections come in three flavours. There is the 'real' section,
32 # like ".data". Then there are the per-procedure or per-variable
33 # sections, generated by -ffunction-sections and -fdata-sections in GCC,
34 # and useful for --gc-sections, which for a variable "foo" might be
35 # ".data.foo". Then there are the linkonce sections, for which the linker
36 # eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
37 # The exact correspondences are:
39 # Section Linkonce section
40 # .text .gnu.linkonce.t.foo
41 # .rodata .gnu.linkonce.r.foo
42 # .data .gnu.linkonce.d.foo
43 # .bss .gnu.linkonce.b.foo
44 # .sdata .gnu.linkonce.s.foo
45 # .sbss .gnu.linkonce.sb.foo
46 # .sdata2 .gnu.linkonce.s2.foo
47 # .sbss2 .gnu.linkonce.sb2.foo
49 # Each of these can also have corresponding .rel.* and .rela.* sections.
51 test -z "$ENTRY" && ENTRY=_start
52 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
53 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
54 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
55 test -z "${ELFSIZE}" && ELFSIZE=32
56 test -z "${ALIGNMENT}" && ALIGNMENT="${ELFSIZE} / 8"
57 CTOR=".ctors ${CONSTRUCTING-0} :
59 ${CONSTRUCTING+${CTOR_START}}
60 /* gcc uses crtbegin.o to find the start of
61 the constructors, so we make sure it is
62 first. Because this is a wildcard, it
63 doesn't matter if the user does not
64 actually link against crtbegin.o; the
65 linker won't look for a file to match a
66 wildcard. The wildcard also means that it
67 doesn't matter which directory crtbegin.o
70 KEEP (*crtbegin*.o(.ctors))
72 /* We don't want to include the .ctor section from
73 the crtend.o file until after the sorted ctors.
74 The .ctor section from the crtend file contains the
75 end of ctors marker and it must be last */
77 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors))
78 KEEP (*(SORT(.ctors.*)))
80 ${CONSTRUCTING+${CTOR_END}}
83 DTOR=" .dtors ${CONSTRUCTING-0} :
85 ${CONSTRUCTING+${DTOR_START}}
86 KEEP (*crtbegin*.o(.dtors))
87 KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors))
88 KEEP (*(SORT(.dtors.*)))
90 ${CONSTRUCTING+${DTOR_END}}
94 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
95 "${LITTLE_OUTPUT_FORMAT}")
96 OUTPUT_ARCH(${OUTPUT_ARCH})
99 ${RELOCATING+${LIB_SEARCH_DIRS}}
100 ${RELOCATING+${EXECUTABLE_SYMBOLS}}
101 ${RELOCATING+${INPUT_FILES}}
102 ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
103 if gld -r is used and the intermediate file has sections starting
104 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
105 bug. But for now assigning the zero vmas works. */}
107 /* There are two memory regions we care about, one from 0 through 0x7F00
108 that is RAM and one from 0x8000 up which is ROM. */
111 RAM (w) : ORIGIN = 0, LENGTH = 0x7F00
112 ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000
117 .data ${RELOCATING-0} :
119 ${RELOCATING+__rdata = .;}
120 ${RELOCATING+__data = .;}
121 ${RELOCATING+${DATA_START_SYMBOLS}}
123 ${RELOCATING+*(.data.*)}
124 ${RELOCATING+*(.gnu.linkonce.d.*)}
125 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
127 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
128 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
129 ${RELOCATING+${OTHER_GOT_SECTIONS}}
130 ${RELOCATING+_edata = .;}
131 ${RELOCATING+PROVIDE (edata = .);}
132 ${RELOCATING+__bss_start = .;}
133 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
134 .bss ${RELOCATING-0} :
138 ${RELOCATING+*(.bss.*)}
139 ${RELOCATING+*(.gnu.linkonce.b.*)}
141 /* Align here to ensure that the .bss section occupies space up to
142 _end. Align after .bss to ensure correct alignment even if the
143 .bss section disappears because there are no input sections. */
144 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
146 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
147 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
148 ${RELOCATING+${OTHER_END_SYMBOLS}}
149 ${RELOCATING+_end = .;}
150 ${RELOCATING+__stack = .;}
151 ${RELOCATING+PROVIDE (end = .);}
153 /* Read-only sections in ROM. */
154 .int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM}
156 .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${RELOCATING+> ROM}
157 ${RELOCATING+${CTOR}}
158 ${RELOCATING+${DTOR}}
159 .jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ROM}
160 .eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ROM}
161 .gcc_except_table : { *(.gcc_except_table) } ${RELOCATING+> ROM}
162 .plt : { *(.plt) } ${RELOCATING+> ROM}
164 .text ${RELOCATING-0} :
166 ${RELOCATING+${TEXT_START_SYMBOLS}}
168 ${RELOCATING+*(.text.*)}
170 /* .gnu.warning sections are handled specially by elf32.em. */
172 ${RELOCATING+*(.gnu.linkonce.t.*)}
173 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
174 } ${RELOCATING+> ROM =${NOP-0}}
175 .init ${RELOCATING-0} :
177 ${RELOCATING+${INIT_START}}
179 ${RELOCATING+${INIT_END}}
180 } ${RELOCATING+> ROM =${NOP-0}}
181 .fini ${RELOCATING-0} :
183 ${RELOCATING+${FINI_START}}
185 ${RELOCATING+${FINI_END}}
186 } ${RELOCATING+> ROM =${NOP-0}}
187 ${RELOCATING+PROVIDE (__etext = .);}
188 ${RELOCATING+PROVIDE (_etext = .);}
189 ${RELOCATING+PROVIDE (etext = .);}
190 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
193 /* Stabs debugging sections. */
194 .stab 0 : { *(.stab) }
195 .stabstr 0 : { *(.stabstr) }
196 .stab.excl 0 : { *(.stab.excl) }
197 .stab.exclstr 0 : { *(.stab.exclstr) }
198 .stab.index 0 : { *(.stab.index) }
199 .stab.indexstr 0 : { *(.stab.indexstr) }
201 .comment 0 : { *(.comment) }
203 /* DWARF debug sections.
204 Symbols in the DWARF debugging sections are relative to the beginning
205 of the section so we begin them at 0. */
208 .debug 0 : { *(.debug) }
209 .line 0 : { *(.line) }
211 /* GNU DWARF 1 extensions */
212 .debug_srcinfo 0 : { *(.debug_srcinfo) }
213 .debug_sfnames 0 : { *(.debug_sfnames) }
215 /* DWARF 1.1 and DWARF 2 */
216 .debug_aranges 0 : { *(.debug_aranges) }
217 .debug_pubnames 0 : { *(.debug_pubnames) }
220 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
221 .debug_abbrev 0 : { *(.debug_abbrev) }
222 .debug_line 0 : { *(.debug_line) }
223 .debug_frame 0 : { *(.debug_frame) }
224 .debug_str 0 : { *(.debug_str) }
225 .debug_loc 0 : { *(.debug_loc) }
226 .debug_macinfo 0 : { *(.debug_macinfo) }
228 /* SGI/MIPS DWARF 2 extensions */
229 .debug_weaknames 0 : { *(.debug_weaknames) }
230 .debug_funcnames 0 : { *(.debug_funcnames) }
231 .debug_typenames 0 : { *(.debug_typenames) }
232 .debug_varnames 0 : { *(.debug_varnames) }
234 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
236 /* These must appear regardless of ${RELOCATING}. */