Commit | Line | Data |
---|---|---|
fe1379d4 ILT |
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 | # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... | |
6 | # (e.g., .PARISC.milli) | |
7 | # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... | |
8 | # (e.g., .PARISC.global) | |
9 | # OTHER_SECTIONS - at the end | |
10 | # EXECUTABLE_SYMBOLS - symbols that must be defined for an | |
11 | # executable (e.g., _DYNAMIC_LINK) | |
12 | # TEXT_START_SYMBOLS - symbols that appear at the start of the | |
13 | # .text section. | |
14 | # DATA_START_SYMBOLS - symbols that appear at the start of the | |
15 | # .data section. | |
16 | # OTHER_BSS_SYMBOLS - symbols that appear at the start of the | |
17 | # .bss section besides __bss_start. | |
01d8a359 | 18 | # EMBEDDED - whether this is for an embedded system. |
fe1379d4 ILT |
19 | # |
20 | # When adding sections, do note that the names of some sections are used | |
21 | # when specifying the start address of the next. | |
22 | # | |
23 | ||
24 | # We use a start address of __start for Irix 5, _start for other | |
25 | # targets. This is for compatibility with Irix 5, and with old MIPS | |
26 | # ELF toolchains. | |
27 | if [ -z "$ENTRY" ]; then | |
7df4ba26 | 28 | case "${target}" in |
fe1379d4 | 29 | mips*-*-irix5*) ENTRY=__start ;; |
09342753 | 30 | mips*-*-linux*) ENTRY=__start ;; |
fe1379d4 ILT |
31 | *) ENTRY=_start ;; |
32 | esac | |
33 | fi | |
34 | ||
01d8a359 RS |
35 | # if this is for an embedded system, don't add SIZEOF_HEADERS. |
36 | if [ -z "$EMBEDDED" ]; then | |
90557a6a | 37 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" |
01d8a359 | 38 | else |
90557a6a | 39 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" |
01d8a359 RS |
40 | fi |
41 | ||
fe1379d4 ILT |
42 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} |
43 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
44 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
45 | INTERP=".interp ${RELOCATING-0} : { *(.interp) }" | |
46 | cat <<EOF | |
47 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", | |
48 | "${LITTLE_OUTPUT_FORMAT}") | |
49 | OUTPUT_ARCH(${ARCH}) | |
50 | ENTRY(${ENTRY}) | |
51 | ||
52 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
53 | ${RELOCATING+/* Do we need any of these for elf? | |
54 | __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} | |
55 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} | |
56 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables | |
57 | if gld -r is used and the intermediate file has sections starting | |
58 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
59 | bug. But for now assigning the zero vmas works. */} | |
60 | SECTIONS | |
61 | { | |
62 | /* Read-only sections, merged into text segment: */ | |
01d8a359 | 63 | ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} |
fe1379d4 ILT |
64 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} |
65 | ${CREATE_SHLIB-${INTERP}} | |
66 | .reginfo ${RELOCATING-0} : { *(.reginfo) } | |
67 | .dynamic ${RELOCATING-0} : { *(.dynamic) } | |
68 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
69 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
70 | .hash ${RELOCATING-0} : { *(.hash) } | |
f5f212fb ILT |
71 | .rel.text ${RELOCATING-0} : |
72 | { *(.rel.text) *(.rel.gnu.linkonce.t*) } | |
73 | .rela.text ${RELOCATING-0} : | |
74 | { *(.rela.text) *(.rela.gnu.linkonce.t*) } | |
75 | .rel.data ${RELOCATING-0} : | |
76 | { *(.rel.data) *(.rel.gnu.linkonce.d*) } | |
77 | .rela.data ${RELOCATING-0} : | |
78 | { *(.rela.data) *(.rela.gnu.linkonce.d*) } | |
79 | .rel.rodata ${RELOCATING-0} : | |
80 | { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } | |
81 | .rela.rodata ${RELOCATING-0} : | |
82 | { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } | |
fe1379d4 ILT |
83 | .rel.got ${RELOCATING-0} : { *(.rel.got) } |
84 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
85 | .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } | |
86 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
87 | .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } | |
88 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
89 | .rel.init ${RELOCATING-0} : { *(.rel.init) } | |
90 | .rela.init ${RELOCATING-0} : { *(.rela.init) } | |
91 | .rel.fini ${RELOCATING-0} : { *(.rel.fini) } | |
92 | .rela.fini ${RELOCATING-0} : { *(.rela.fini) } | |
93 | .rel.bss ${RELOCATING-0} : { *(.rel.bss) } | |
94 | .rela.bss ${RELOCATING-0} : { *(.rela.bss) } | |
95 | .rel.plt ${RELOCATING-0} : { *(.rel.plt) } | |
96 | .rela.plt ${RELOCATING-0} : { *(.rela.plt) } | |
f5f212fb | 97 | .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) } |
fe1379d4 ILT |
98 | .rodata1 ${RELOCATING-0} : { *(.rodata1) } |
99 | .init ${RELOCATING-0} : { *(.init) } =${NOP-0} | |
100 | .text ${RELOCATING-0} : | |
101 | { | |
4fc7ca82 | 102 | ${RELOCATING+${TEXT_START_SYMBOLS}} |
fe1379d4 ILT |
103 | *(.text) |
104 | *(.stub) | |
105 | /* .gnu.warning sections are handled specially by elf32.em. */ | |
106 | *(.gnu.warning) | |
e7886d4b ILT |
107 | ${RELOCATING+*(.gnu.linkonce.t*)} |
108 | ${RELOCATING+*(.mips16.fn.*)} | |
109 | ${RELOCATING+*(.mips16.call.*)} | |
fe1379d4 | 110 | } =${NOP-0} |
4fc7ca82 ILT |
111 | ${RELOCATING+_etext = .;} |
112 | ${RELOCATING+PROVIDE (etext = .);} | |
fe1379d4 ILT |
113 | .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} |
114 | ||
115 | /* Adjust the address for the data segment. We want to adjust up to | |
116 | the same address within the page on the next page up. It would | |
117 | be more correct to do this: | |
118 | ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) | |
119 | + ((ALIGN(8) + ${MAXPAGESIZE} - ALIGN(${MAXPAGESIZE})) | |
120 | & (${MAXPAGESIZE} - 1)};} | |
121 | The current expression does not correctly handle the case of a | |
122 | text segment ending precisely at the end of a page; it causes the | |
123 | data segment to skip a page. The above expression does not have | |
124 | this problem, but it will currently (2/95) cause BFD to allocate | |
125 | a single segment, combining both text and data, for this case. | |
126 | This will prevent the text segment from being shared among | |
127 | multiple executions of the program; I think that is more | |
128 | important than losing a page of the virtual address space (note | |
129 | that no actual memory is lost; the page which is skipped can not | |
130 | be referenced). */ | |
2adb092c ILT |
131 | ${CREATE_SHLIB-${RELOCATING+. += ${DATA_ADDR} - ${TEXT_START_ADDR};}} |
132 | ${CREATE_SHLIB-${RELOCATING+. += 0x10000;}} | |
133 | ${CREATE_SHLIB+${RELOCATING+. = ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1));}} | |
fe1379d4 ILT |
134 | .data ${RELOCATING-0} : |
135 | { | |
4fc7ca82 | 136 | ${RELOCATING+${DATA_START_SYMBOLS}} |
fe1379d4 | 137 | *(.data) |
f5f212fb | 138 | *(.gnu.linkonce.d*) |
fe1379d4 ILT |
139 | ${CONSTRUCTING+CONSTRUCTORS} |
140 | } | |
141 | .data1 ${RELOCATING-0} : { *(.data1) } | |
142 | .ctors ${RELOCATING-0} : { *(.ctors) } | |
143 | .dtors ${RELOCATING-0} : { *(.dtors) } | |
144 | ${RELOCATING+${OTHER_GOT_SYMBOLS}} | |
145 | .got ${RELOCATING-0} : | |
146 | { | |
147 | *(.got.plt) *(.got) | |
148 | } | |
149 | /* We want the small data sections together, so single-instruction offsets | |
150 | can access them all, and initialized data all before uninitialized, so | |
151 | we can shorten the on-disk segment size. */ | |
152 | .sdata ${RELOCATING-0} : { *(.sdata) } | |
153 | ${RELOCATING+${OTHER_READWRITE_SECTIONS}} | |
4fc7ca82 ILT |
154 | ${RELOCATING+_edata = .;} |
155 | ${RELOCATING+PROVIDE (edata = .);} | |
156 | ${RELOCATING+__bss_start = .;} | |
157 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} | |
fe1379d4 ILT |
158 | .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } |
159 | .bss ${RELOCATING-0} : | |
160 | { | |
161 | *(.dynbss) | |
162 | *(.bss) | |
163 | *(COMMON) | |
164 | } | |
4fc7ca82 ILT |
165 | ${RELOCATING+_end = . ;} |
166 | ${RELOCATING+PROVIDE (end = .);} | |
fe1379d4 ILT |
167 | |
168 | /* These are needed for ELF backends which have not yet been | |
169 | converted to the new style linker. */ | |
170 | .stab 0 : { *(.stab) } | |
171 | .stabstr 0 : { *(.stabstr) } | |
172 | ||
173 | /* DWARF debug sections. | |
264677bb JM |
174 | Symbols in the DWARF debugging sections are relative to the beginning |
175 | of the section so we begin them at 0. */ | |
176 | ||
177 | /* DWARF 1 */ | |
fe1379d4 | 178 | .debug 0 : { *(.debug) } |
264677bb JM |
179 | .line 0 : { *(.line) } |
180 | ||
181 | /* GNU DWARF 1 extensions */ | |
182 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | |
183 | .debug_sfnames 0 : { *(.debug_sfnames) } | |
184 | ||
185 | /* DWARF 1.1 and DWARF 2 */ | |
186 | .debug_aranges 0 : { *(.debug_aranges) } | |
187 | .debug_pubnames 0 : { *(.debug_pubnames) } | |
188 | ||
189 | /* DWARF 2 */ | |
9193c60b JM |
190 | .debug_info 0 : { *(.debug_info) } |
191 | .debug_abbrev 0 : { *(.debug_abbrev) } | |
192 | .debug_line 0 : { *(.debug_line) } | |
193 | .debug_frame 0 : { *(.debug_frame) } | |
264677bb JM |
194 | .debug_str 0 : { *(.debug_str) } |
195 | .debug_loc 0 : { *(.debug_loc) } | |
196 | .debug_macinfo 0 : { *(.debug_macinfo) } | |
197 | ||
198 | /* SGI/MIPS DWARF 2 extensions */ | |
199 | .debug_weaknames 0 : { *(.debug_weaknames) } | |
200 | .debug_funcnames 0 : { *(.debug_funcnames) } | |
201 | .debug_typenames 0 : { *(.debug_typenames) } | |
202 | .debug_varnames 0 : { *(.debug_varnames) } | |
fe1379d4 ILT |
203 | |
204 | /* These must appear regardless of ${RELOCATING}. */ | |
205 | ${OTHER_SECTIONS} | |
206 | } | |
207 | EOF |