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+${DATA_START_SYMBOLS}}
122 ${RELOCATING+*(.data.*)}
123 ${RELOCATING+*(.gnu.linkonce.d.*)}
124 ${CONSTRUCTING+SORT(CONSTRUCTORS)}
126 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
127 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
128 ${RELOCATING+${OTHER_GOT_SECTIONS}}
129 ${RELOCATING+_edata = .;}
130 ${RELOCATING+PROVIDE (edata = .);}
131 ${RELOCATING+__bss_start = .;}
132 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
133 .bss ${RELOCATING-0} :
137 ${RELOCATING+*(.bss.*)}
138 ${RELOCATING+*(.gnu.linkonce.b.*)}
140 /* Align here to ensure that the .bss section occupies space up to
141 _end. Align after .bss to ensure correct alignment even if the
142 .bss section disappears because there are no input sections. */
143 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
145 ${RELOCATING+${OTHER_BSS_SECTIONS}}
146 ${RELOCATING+. = ALIGN(${ALIGNMENT});}
147 ${RELOCATING+_end = .;}
148 ${RELOCATING+__stack = .;}
149 ${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
150 ${RELOCATING+PROVIDE (end = .);}
152 /* Read-only sections in ROM. */
153 .int_vec ${RELOCATING-0} : { *(.int_vec) } > ROM
155 .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } > ROM
156 ${RELOCATING+${CTOR}}
157 ${RELOCATING+${DTOR}}
158 .eh_frame : { KEEP (*(.eh_frame)) } > ROM
159 .gcc_except_table : { *(.gcc_except_table) } > ROM
160 .plt : { *(.plt) } > ROM
162 .text ${RELOCATING-0} :
164 ${RELOCATING+${TEXT_START_SYMBOLS}}
166 ${RELOCATING+*(.text.*)}
168 /* .gnu.warning sections are handled specially by elf32.em. */
170 ${RELOCATING+*(.gnu.linkonce.t.*)}
171 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
173 .init ${RELOCATING-0} :
175 ${RELOCATING+${INIT_START}}
177 ${RELOCATING+${INIT_END}}
179 .fini ${RELOCATING-0} :
181 ${RELOCATING+${FINI_START}}
183 ${RELOCATING+${FINI_END}}
185 ${RELOCATING+PROVIDE (__etext = .);}
186 ${RELOCATING+PROVIDE (_etext = .);}
187 ${RELOCATING+PROVIDE (etext = .);}
188 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
191 /* Stabs debugging sections. */
192 .stab 0 : { *(.stab) }
193 .stabstr 0 : { *(.stabstr) }
194 .stab.excl 0 : { *(.stab.excl) }
195 .stab.exclstr 0 : { *(.stab.exclstr) }
196 .stab.index 0 : { *(.stab.index) }
197 .stab.indexstr 0 : { *(.stab.indexstr) }
199 .comment 0 : { *(.comment) }
201 /* DWARF debug sections.
202 Symbols in the DWARF debugging sections are relative to the beginning
203 of the section so we begin them at 0. */
206 .debug 0 : { *(.debug) }
207 .line 0 : { *(.line) }
209 /* GNU DWARF 1 extensions */
210 .debug_srcinfo 0 : { *(.debug_srcinfo) }
211 .debug_sfnames 0 : { *(.debug_sfnames) }
213 /* DWARF 1.1 and DWARF 2 */
214 .debug_aranges 0 : { *(.debug_aranges) }
215 .debug_pubnames 0 : { *(.debug_pubnames) }
218 .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
219 .debug_abbrev 0 : { *(.debug_abbrev) }
220 .debug_line 0 : { *(.debug_line) }
221 .debug_frame 0 : { *(.debug_frame) }
222 .debug_str 0 : { *(.debug_str) }
223 .debug_loc 0 : { *(.debug_loc) }
224 .debug_macinfo 0 : { *(.debug_macinfo) }
226 /* SGI/MIPS DWARF 2 extensions */
227 .debug_weaknames 0 : { *(.debug_weaknames) }
228 .debug_funcnames 0 : { *(.debug_funcnames) }
229 .debug_typenames 0 : { *(.debug_typenames) }
230 .debug_varnames 0 : { *(.debug_varnames) }
232 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
234 /* These must appear regardless of ${RELOCATING}. */