1 |
38 |
julius |
#
|
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
|
14 |
|
|
# .text section.
|
15 |
|
|
# DATA_START_SYMBOLS - symbols that appear at the start of the
|
16 |
|
|
# .data section.
|
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.
|
26 |
|
|
#
|
27 |
|
|
# When adding sections, do note that the names of some sections are used
|
28 |
|
|
# when specifying the start address of the next.
|
29 |
|
|
#
|
30 |
|
|
|
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:
|
38 |
|
|
#
|
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
|
48 |
|
|
#
|
49 |
|
|
# Each of these can also have corresponding .rel.* and .rela.* sections.
|
50 |
|
|
|
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} :
|
58 |
|
|
{
|
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
|
68 |
|
|
is in. */
|
69 |
|
|
|
70 |
|
|
KEEP (*crtbegin.o(.ctors))
|
71 |
|
|
KEEP (*crtbegin?.o(.ctors))
|
72 |
|
|
|
73 |
|
|
/* We don't want to include the .ctor section from
|
74 |
|
|
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 */
|
77 |
|
|
|
78 |
|
|
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors))
|
79 |
|
|
KEEP (*(SORT(.ctors.*)))
|
80 |
|
|
KEEP (*(.ctors))
|
81 |
|
|
${CONSTRUCTING+${CTOR_END}}
|
82 |
|
|
} > ROM"
|
83 |
|
|
|
84 |
|
|
DTOR=" .dtors ${CONSTRUCTING-0} :
|
85 |
|
|
{
|
86 |
|
|
${CONSTRUCTING+${DTOR_START}}
|
87 |
|
|
KEEP (*crtbegin.o(.dtors))
|
88 |
|
|
KEEP (*crtbegin?.o(.dtors))
|
89 |
|
|
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors))
|
90 |
|
|
KEEP (*(SORT(.dtors.*)))
|
91 |
|
|
KEEP (*(.dtors))
|
92 |
|
|
${CONSTRUCTING+${DTOR_END}}
|
93 |
|
|
} > ROM"
|
94 |
|
|
|
95 |
|
|
cat <
|
96 |
|
|
OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
|
97 |
|
|
"${LITTLE_OUTPUT_FORMAT}")
|
98 |
|
|
OUTPUT_ARCH(${OUTPUT_ARCH})
|
99 |
|
|
${RELOCATING+ENTRY(${ENTRY})}
|
100 |
|
|
|
101 |
|
|
${RELOCATING+${LIB_SEARCH_DIRS}}
|
102 |
|
|
${RELOCATING+${EXECUTABLE_SYMBOLS}}
|
103 |
|
|
${RELOCATING+${INPUT_FILES}}
|
104 |
|
|
${RELOCATING- /* For some reason, the Solaris linker makes bad executables
|
105 |
|
|
if gld -r is used and the intermediate file has sections starting
|
106 |
|
|
at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
|
107 |
|
|
bug. But for now assigning the zero vmas works. */}
|
108 |
|
|
|
109 |
|
|
/* There are two memory regions we care about, one from 0 through 0x7F00
|
110 |
|
|
that is RAM and one from 0x8000 up which is ROM. */
|
111 |
|
|
MEMORY
|
112 |
|
|
{
|
113 |
|
|
RAM (w) : ORIGIN = 0, LENGTH = 0x7F00
|
114 |
|
|
ROM (!w) : ORIGIN = 0x8000, LENGTH = 0xFF8000
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
SECTIONS
|
118 |
|
|
{
|
119 |
|
|
.data ${RELOCATING-0} :
|
120 |
|
|
{
|
121 |
|
|
${RELOCATING+__rdata = .;}
|
122 |
|
|
${RELOCATING+__data = .;}
|
123 |
|
|
${RELOCATING+${DATA_START_SYMBOLS}}
|
124 |
|
|
*(.data)
|
125 |
|
|
${RELOCATING+*(.data.*)}
|
126 |
|
|
${RELOCATING+*(.gnu.linkonce.d.*)}
|
127 |
|
|
${CONSTRUCTING+SORT(CONSTRUCTORS)}
|
128 |
|
|
} > RAM
|
129 |
|
|
${RELOCATING+${OTHER_READWRITE_SECTIONS}}
|
130 |
|
|
${RELOCATING+${OTHER_GOT_SYMBOLS}}
|
131 |
|
|
${RELOCATING+${OTHER_GOT_SECTIONS}}
|
132 |
|
|
${RELOCATING+_edata = .;}
|
133 |
|
|
${RELOCATING+PROVIDE (edata = .);}
|
134 |
|
|
${RELOCATING+__bss_start = .;}
|
135 |
|
|
${RELOCATING+${OTHER_BSS_SYMBOLS}}
|
136 |
|
|
.bss ${RELOCATING-0} :
|
137 |
|
|
{
|
138 |
|
|
*(.dynbss)
|
139 |
|
|
*(.bss)
|
140 |
|
|
${RELOCATING+*(.bss.*)}
|
141 |
|
|
${RELOCATING+*(.gnu.linkonce.b.*)}
|
142 |
|
|
*(COMMON)
|
143 |
|
|
/* Align here to ensure that the .bss section occupies space up to
|
144 |
|
|
_end. Align after .bss to ensure correct alignment even if the
|
145 |
|
|
.bss section disappears because there are no input sections. */
|
146 |
|
|
${RELOCATING+. = ALIGN(${ALIGNMENT});}
|
147 |
|
|
} > RAM
|
148 |
|
|
${RELOCATING+${OTHER_BSS_END_SYMBOLS}}
|
149 |
|
|
${RELOCATING+. = ALIGN(${ALIGNMENT});}
|
150 |
|
|
${RELOCATING+${OTHER_END_SYMBOLS}}
|
151 |
|
|
${RELOCATING+_end = .;}
|
152 |
|
|
${RELOCATING+__stack = .;}
|
153 |
|
|
${RELOCATING+PROVIDE (end = .);}
|
154 |
|
|
|
155 |
|
|
/* Read-only sections in ROM. */
|
156 |
|
|
.int_vec ${RELOCATING-0} : { *(.int_vec) } ${RELOCATING+> ROM}
|
157 |
|
|
|
158 |
|
|
.rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.rodata.*)} ${RELOCATING+*(.gnu.linkonce.r.*)} } ${RELOCATING+> ROM}
|
159 |
|
|
${RELOCATING+${CTOR}}
|
160 |
|
|
${RELOCATING+${DTOR}}
|
161 |
|
|
.jcr : { KEEP (*(.jcr)) } ${RELOCATING+> ROM}
|
162 |
|
|
.eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ROM}
|
163 |
|
|
.gcc_except_table : { *(.gcc_except_table) } ${RELOCATING+> ROM}
|
164 |
|
|
.plt : { *(.plt) } ${RELOCATING+> ROM}
|
165 |
|
|
|
166 |
|
|
.text ${RELOCATING-0} :
|
167 |
|
|
{
|
168 |
|
|
${RELOCATING+${TEXT_START_SYMBOLS}}
|
169 |
|
|
*(.text)
|
170 |
|
|
${RELOCATING+*(.text.*)}
|
171 |
|
|
*(.stub)
|
172 |
|
|
/* .gnu.warning sections are handled specially by elf32.em. */
|
173 |
|
|
*(.gnu.warning)
|
174 |
|
|
${RELOCATING+*(.gnu.linkonce.t.*)}
|
175 |
|
|
${RELOCATING+${OTHER_TEXT_SECTIONS}}
|
176 |
|
|
} ${RELOCATING+> ROM =${NOP-0}}
|
177 |
|
|
.init ${RELOCATING-0} :
|
178 |
|
|
{
|
179 |
|
|
${RELOCATING+${INIT_START}}
|
180 |
|
|
KEEP (*(.init))
|
181 |
|
|
${RELOCATING+${INIT_END}}
|
182 |
|
|
} ${RELOCATING+> ROM =${NOP-0}}
|
183 |
|
|
.fini ${RELOCATING-0} :
|
184 |
|
|
{
|
185 |
|
|
${RELOCATING+${FINI_START}}
|
186 |
|
|
KEEP (*(.fini))
|
187 |
|
|
${RELOCATING+${FINI_END}}
|
188 |
|
|
} ${RELOCATING+> ROM =${NOP-0}}
|
189 |
|
|
${RELOCATING+PROVIDE (__etext = .);}
|
190 |
|
|
${RELOCATING+PROVIDE (_etext = .);}
|
191 |
|
|
${RELOCATING+PROVIDE (etext = .);}
|
192 |
|
|
${RELOCATING+${OTHER_READONLY_SECTIONS}}
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
/* Stabs debugging sections. */
|
196 |
|
|
.stab 0 : { *(.stab) }
|
197 |
|
|
.stabstr 0 : { *(.stabstr) }
|
198 |
|
|
.stab.excl 0 : { *(.stab.excl) }
|
199 |
|
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
200 |
|
|
.stab.index 0 : { *(.stab.index) }
|
201 |
|
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
202 |
|
|
|
203 |
|
|
.comment 0 : { *(.comment) }
|
204 |
|
|
|
205 |
|
|
/* DWARF debug sections.
|
206 |
|
|
Symbols in the DWARF debugging sections are relative to the beginning
|
207 |
|
|
of the section so we begin them at 0. */
|
208 |
|
|
|
209 |
|
|
/* DWARF 1 */
|
210 |
|
|
.debug 0 : { *(.debug) }
|
211 |
|
|
.line 0 : { *(.line) }
|
212 |
|
|
|
213 |
|
|
/* GNU DWARF 1 extensions */
|
214 |
|
|
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
215 |
|
|
.debug_sfnames 0 : { *(.debug_sfnames) }
|
216 |
|
|
|
217 |
|
|
/* DWARF 1.1 and DWARF 2 */
|
218 |
|
|
.debug_aranges 0 : { *(.debug_aranges) }
|
219 |
|
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
220 |
|
|
|
221 |
|
|
/* DWARF 2 */
|
222 |
|
|
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
|
223 |
|
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
224 |
|
|
.debug_line 0 : { *(.debug_line) }
|
225 |
|
|
.debug_frame 0 : { *(.debug_frame) }
|
226 |
|
|
.debug_str 0 : { *(.debug_str) }
|
227 |
|
|
.debug_loc 0 : { *(.debug_loc) }
|
228 |
|
|
.debug_macinfo 0 : { *(.debug_macinfo) }
|
229 |
|
|
|
230 |
|
|
/* SGI/MIPS DWARF 2 extensions */
|
231 |
|
|
.debug_weaknames 0 : { *(.debug_weaknames) }
|
232 |
|
|
.debug_funcnames 0 : { *(.debug_funcnames) }
|
233 |
|
|
.debug_typenames 0 : { *(.debug_typenames) }
|
234 |
|
|
.debug_varnames 0 : { *(.debug_varnames) }
|
235 |
|
|
|
236 |
|
|
${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
|
237 |
|
|
|
238 |
|
|
/* These must appear regardless of ${RELOCATING}. */
|
239 |
|
|
${OTHER_SECTIONS}
|
240 |
|
|
}
|
241 |
|
|
EOF
|