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. | |
18 | # | |
19 | # When adding sections, do note that the names of some sections are used | |
20 | # when specifying the start address of the next. | |
21 | # | |
22 | ||
23 | # We use a start address of __start for Irix 5, _start for other | |
24 | # targets. This is for compatibility with Irix 5, and with old MIPS | |
25 | # ELF toolchains. | |
26 | if [ -z "$ENTRY" ]; then | |
7df4ba26 | 27 | case "${target}" in |
fe1379d4 ILT |
28 | mips*-*-irix5*) ENTRY=__start ;; |
29 | *) ENTRY=_start ;; | |
30 | esac | |
31 | fi | |
32 | ||
33 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
34 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
35 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
36 | INTERP=".interp ${RELOCATING-0} : { *(.interp) }" | |
37 | cat <<EOF | |
38 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", | |
39 | "${LITTLE_OUTPUT_FORMAT}") | |
40 | OUTPUT_ARCH(${ARCH}) | |
41 | ENTRY(${ENTRY}) | |
42 | ||
43 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
44 | ${RELOCATING+/* Do we need any of these for elf? | |
45 | __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} | |
46 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} | |
47 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables | |
48 | if gld -r is used and the intermediate file has sections starting | |
49 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
50 | bug. But for now assigning the zero vmas works. */} | |
51 | SECTIONS | |
52 | { | |
53 | /* Read-only sections, merged into text segment: */ | |
54 | ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}} | |
55 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR} + SIZEOF_HEADERS;}} | |
56 | ${CREATE_SHLIB-${INTERP}} | |
57 | .reginfo ${RELOCATING-0} : { *(.reginfo) } | |
58 | .dynamic ${RELOCATING-0} : { *(.dynamic) } | |
59 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
60 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
61 | .hash ${RELOCATING-0} : { *(.hash) } | |
62 | .rel.text ${RELOCATING-0} : { *(.rel.text) } | |
63 | .rela.text ${RELOCATING-0} : { *(.rela.text) } | |
64 | .rel.data ${RELOCATING-0} : { *(.rel.data) } | |
65 | .rela.data ${RELOCATING-0} : { *(.rela.data) } | |
66 | .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) } | |
67 | .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } | |
68 | .rel.got ${RELOCATING-0} : { *(.rel.got) } | |
69 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
70 | .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } | |
71 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
72 | .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } | |
73 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
74 | .rel.init ${RELOCATING-0} : { *(.rel.init) } | |
75 | .rela.init ${RELOCATING-0} : { *(.rela.init) } | |
76 | .rel.fini ${RELOCATING-0} : { *(.rel.fini) } | |
77 | .rela.fini ${RELOCATING-0} : { *(.rela.fini) } | |
78 | .rel.bss ${RELOCATING-0} : { *(.rel.bss) } | |
79 | .rela.bss ${RELOCATING-0} : { *(.rela.bss) } | |
80 | .rel.plt ${RELOCATING-0} : { *(.rel.plt) } | |
81 | .rela.plt ${RELOCATING-0} : { *(.rela.plt) } | |
82 | .rodata ${RELOCATING-0} : { *(.rodata) } | |
83 | .rodata1 ${RELOCATING-0} : { *(.rodata1) } | |
84 | .init ${RELOCATING-0} : { *(.init) } =${NOP-0} | |
85 | .text ${RELOCATING-0} : | |
86 | { | |
87 | ${CREATE_SHLIB-${RELOCATING+${TEXT_START_SYMBOLS}}} | |
88 | *(.text) | |
89 | *(.stub) | |
90 | /* .gnu.warning sections are handled specially by elf32.em. */ | |
91 | *(.gnu.warning) | |
92 | } =${NOP-0} | |
93 | ${CREATE_SHLIB-${RELOCATING+_etext = .;}} | |
94 | ${CREATE_SHLIB-${RELOCATING+PROVIDE (etext = .);}} | |
95 | .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} | |
96 | ||
97 | /* Adjust the address for the data segment. We want to adjust up to | |
98 | the same address within the page on the next page up. It would | |
99 | be more correct to do this: | |
100 | ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) | |
101 | + ((ALIGN(8) + ${MAXPAGESIZE} - ALIGN(${MAXPAGESIZE})) | |
102 | & (${MAXPAGESIZE} - 1)};} | |
103 | The current expression does not correctly handle the case of a | |
104 | text segment ending precisely at the end of a page; it causes the | |
105 | data segment to skip a page. The above expression does not have | |
106 | this problem, but it will currently (2/95) cause BFD to allocate | |
107 | a single segment, combining both text and data, for this case. | |
108 | This will prevent the text segment from being shared among | |
109 | multiple executions of the program; I think that is more | |
110 | important than losing a page of the virtual address space (note | |
111 | that no actual memory is lost; the page which is skipped can not | |
112 | be referenced). */ | |
113 | ${CREATE_SHLIB-${RELOCATING+. += ${DATA_ADDR} - ${TEXT_START_ADDR};}} | |
114 | ${CREATE_SHLIB+${RELOCATING+. += 0x10000;}} | |
115 | .data ${RELOCATING-0} : | |
116 | { | |
117 | ${CREATE_SHLIB-${RELOCATING+${DATA_START_SYMBOLS}}} | |
118 | *(.data) | |
119 | ${CONSTRUCTING+CONSTRUCTORS} | |
120 | } | |
121 | .data1 ${RELOCATING-0} : { *(.data1) } | |
122 | .ctors ${RELOCATING-0} : { *(.ctors) } | |
123 | .dtors ${RELOCATING-0} : { *(.dtors) } | |
124 | ${RELOCATING+${OTHER_GOT_SYMBOLS}} | |
125 | .got ${RELOCATING-0} : | |
126 | { | |
127 | *(.got.plt) *(.got) | |
128 | } | |
129 | /* We want the small data sections together, so single-instruction offsets | |
130 | can access them all, and initialized data all before uninitialized, so | |
131 | we can shorten the on-disk segment size. */ | |
132 | .sdata ${RELOCATING-0} : { *(.sdata) } | |
133 | ${RELOCATING+${OTHER_READWRITE_SECTIONS}} | |
134 | ${CREATE_SHLIB-${RELOCATING+_edata = .;}} | |
135 | ${CREATE_SHLIB-${RELOCATING+PROVIDE (edata = .);}} | |
136 | ${CREATE_SHLIB-${RELOCATING+__bss_start = .;}} | |
137 | ${CREATE_SHLIB-${RELOCATING+${OTHER_BSS_SYMBOLS}}} | |
138 | .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } | |
139 | .bss ${RELOCATING-0} : | |
140 | { | |
141 | *(.dynbss) | |
142 | *(.bss) | |
143 | *(COMMON) | |
144 | } | |
145 | ${CREATE_SHLIB-${RELOCATING+_end = . ;}} | |
146 | ${CREATE_SHLIB-${RELOCATING+PROVIDE (end = .);}} | |
147 | ||
148 | /* These are needed for ELF backends which have not yet been | |
149 | converted to the new style linker. */ | |
150 | .stab 0 : { *(.stab) } | |
151 | .stabstr 0 : { *(.stabstr) } | |
152 | ||
153 | /* DWARF debug sections. | |
154 | Symbols in the .debug DWARF section are relative to the beginning of the | |
155 | section so we begin .debug at 0. It's not clear yet what needs to happen | |
156 | for the others. */ | |
157 | .debug 0 : { *(.debug) } | |
158 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | |
159 | .debug_aranges 0 : { *(.debug_aranges) } | |
160 | .debug_pubnames 0 : { *(.debug_pubnames) } | |
161 | .debug_sfnames 0 : { *(.debug_sfnames) } | |
162 | .line 0 : { *(.line) } | |
163 | ||
164 | /* These must appear regardless of ${RELOCATING}. */ | |
165 | ${OTHER_SECTIONS} | |
166 | } | |
167 | EOF |