Fri Jun 5 23:42:43 1998 Alan Modra <alan@spri.levels.unisa.edu.au>
[deliverable/binutils-gdb.git] / ld / scripttempl / elf.sc
... / ...
CommitLineData
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#
28# When adding sections, do note that the names of some sections are used
29# when specifying the start address of the next.
30#
31
32test -z "$ENTRY" && ENTRY=_start
33test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
34test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
35if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
36test -z "${ELFSIZE}" && ELFSIZE=32
37test "$LD_FLAG" = "N" && DATA_ADDR=.
38INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
39PLT=".plt ${RELOCATING-0} : { *(.plt) }"
40DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
41
42# if this is for an embedded system, don't add SIZEOF_HEADERS.
43if [ -z "$EMBEDDED" ]; then
44 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
45else
46 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
47fi
48
49cat <<EOF
50OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
51 "${LITTLE_OUTPUT_FORMAT}")
52OUTPUT_ARCH(${OUTPUT_ARCH})
53ENTRY(${ENTRY})
54
55${RELOCATING+${LIB_SEARCH_DIRS}}
56${RELOCATING+/* Do we need any of these for elf?
57 __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */}
58${RELOCATING+${EXECUTABLE_SYMBOLS}}
59${RELOCATING- /* For some reason, the Solaris linker makes bad executables
60 if gld -r is used and the intermediate file has sections starting
61 at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld
62 bug. But for now assigning the zero vmas works. */}
63SECTIONS
64{
65 /* Read-only sections, merged into text segment: */
66 ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}}
67 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
68 ${CREATE_SHLIB-${INTERP}}
69 ${INITIAL_READONLY_SECTIONS}
70 ${TEXT_DYNAMIC+${DYNAMIC}}
71 .hash ${RELOCATING-0} : { *(.hash) }
72 .dynsym ${RELOCATING-0} : { *(.dynsym) }
73 .dynstr ${RELOCATING-0} : { *(.dynstr) }
74 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
75 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
76 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
77 .rel.text ${RELOCATING-0} :
78 { *(.rel.text) ${RELOCATING+*(.rel.gnu.linkonce.t*)} }
79 .rela.text ${RELOCATING-0} :
80 { *(.rela.text) ${RELOCATING+*(.rela.gnu.linkonce.t*)} }
81 .rel.data ${RELOCATING-0} :
82 { *(.rel.data) ${RELOCATING+*(.rel.gnu.linkonce.d*)} }
83 .rela.data ${RELOCATING-0} :
84 { *(.rela.data) ${RELOCATING+*(.rela.gnu.linkonce.d*)} }
85 .rel.rodata ${RELOCATING-0} :
86 { *(.rel.rodata) ${RELOCATING+*(.rel.gnu.linkonce.r*)} }
87 .rela.rodata ${RELOCATING-0} :
88 { *(.rela.rodata) ${RELOCATING+*(.rela.gnu.linkonce.r*)} }
89 .rel.got ${RELOCATING-0} : { *(.rel.got) }
90 .rela.got ${RELOCATING-0} : { *(.rela.got) }
91 .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) }
92 .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) }
93 .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) }
94 .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) }
95 .rel.init ${RELOCATING-0} : { *(.rel.init) }
96 .rela.init ${RELOCATING-0} : { *(.rela.init) }
97 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
98 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
99 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
100 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
101 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
102 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
103 .init ${RELOCATING-0} : { *(.init) } =${NOP-0}
104 ${DATA_PLT-${PLT}}
105 .text ${RELOCATING-0} :
106 {
107 ${RELOCATING+${TEXT_START_SYMBOLS}}
108 *(.text)
109 *(.stub)
110 /* .gnu.warning sections are handled specially by elf32.em. */
111 *(.gnu.warning)
112 ${RELOCATING+*(.gnu.linkonce.t*)}
113 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
114 } =${NOP-0}
115 ${RELOCATING+_etext = .;}
116 ${RELOCATING+PROVIDE (etext = .);}
117 .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0}
118 .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.gnu.linkonce.r*)} }
119 .rodata1 ${RELOCATING-0} : { *(.rodata1) }
120 ${RELOCATING+${OTHER_READONLY_SECTIONS}}
121
122 /* Adjust the address for the data segment. We want to adjust up to
123 the same address within the page on the next page up. */
124 ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
125 ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}}
126
127 .data ${RELOCATING-0} :
128 {
129 ${RELOCATING+${DATA_START_SYMBOLS}}
130 *(.data)
131 ${RELOCATING+*(.gnu.linkonce.d*)}
132 ${CONSTRUCTING+CONSTRUCTORS}
133 }
134 .data1 ${RELOCATING-0} : { *(.data1) }
135 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
136 .ctors ${RELOCATING-0} :
137 {
138 ${CONSTRUCTING+${CTOR_START}}
139 *(SORT(.ctors.*))
140 *(.ctors)
141 ${CONSTRUCTING+${CTOR_END}}
142 }
143 .dtors ${RELOCATING-0} :
144 {
145 ${CONSTRUCTING+${DTOR_START}}
146 *(SORT(.dtors.*))
147 *(.dtors)
148 ${CONSTRUCTING+${DTOR_END}}
149 }
150 ${DATA_PLT+${PLT}}
151 ${RELOCATING+${OTHER_GOT_SYMBOLS}}
152 .got ${RELOCATING-0} : { *(.got.plt) *(.got) }
153 ${TEXT_DYNAMIC-${DYNAMIC}}
154 /* We want the small data sections together, so single-instruction offsets
155 can access them all, and initialized data all before uninitialized, so
156 we can shorten the on-disk segment size. */
157 .sdata ${RELOCATING-0} : { *(.sdata) }
158 ${RELOCATING+${OTHER_GOT_SECTIONS}}
159 ${RELOCATING+_edata = .;}
160 ${RELOCATING+PROVIDE (edata = .);}
161 ${RELOCATING+__bss_start = .;}
162 ${RELOCATING+${OTHER_BSS_SYMBOLS}}
163 .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) }
164 .bss ${RELOCATING-0} :
165 {
166 *(.dynbss)
167 *(.bss)
168 *(COMMON)
169 }
170 ${RELOCATING+. = ALIGN(${ELFSIZE} / 8);}
171 ${RELOCATING+_end = . ;}
172 ${RELOCATING+PROVIDE (end = .);}
173
174 /* Stabs debugging sections. */
175 .stab 0 : { *(.stab) }
176 .stabstr 0 : { *(.stabstr) }
177 .stab.excl 0 : { *(.stab.excl) }
178 .stab.exclstr 0 : { *(.stab.exclstr) }
179 .stab.index 0 : { *(.stab.index) }
180 .stab.indexstr 0 : { *(.stab.indexstr) }
181
182 .comment 0 : { *(.comment) }
183
184 /* DWARF debug sections.
185 Symbols in the DWARF debugging sections are relative to the beginning
186 of the section so we begin them at 0. */
187
188 /* DWARF 1 */
189 .debug 0 : { *(.debug) }
190 .line 0 : { *(.line) }
191
192 /* GNU DWARF 1 extensions */
193 .debug_srcinfo 0 : { *(.debug_srcinfo) }
194 .debug_sfnames 0 : { *(.debug_sfnames) }
195
196 /* DWARF 1.1 and DWARF 2 */
197 .debug_aranges 0 : { *(.debug_aranges) }
198 .debug_pubnames 0 : { *(.debug_pubnames) }
199
200 /* DWARF 2 */
201 .debug_info 0 : { *(.debug_info) }
202 .debug_abbrev 0 : { *(.debug_abbrev) }
203 .debug_line 0 : { *(.debug_line) }
204 .debug_frame 0 : { *(.debug_frame) }
205 .debug_str 0 : { *(.debug_str) }
206 .debug_loc 0 : { *(.debug_loc) }
207 .debug_macinfo 0 : { *(.debug_macinfo) }
208
209 /* SGI/MIPS DWARF 2 extensions */
210 .debug_weaknames 0 : { *(.debug_weaknames) }
211 .debug_funcnames 0 : { *(.debug_funcnames) }
212 .debug_typenames 0 : { *(.debug_typenames) }
213 .debug_varnames 0 : { *(.debug_varnames) }
214
215 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
216
217 /* These must appear regardless of ${RELOCATING}. */
218 ${OTHER_SECTIONS}
219}
220EOF
This page took 0.02369 seconds and 4 git commands to generate.