Commit | Line | Data |
---|---|---|
5f16938d MM |
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 | |
c2b6884b | 5 | # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... |
5f16938d | 6 | # (e.g., .PARISC.milli) |
c2b6884b | 7 | # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... |
5f16938d MM |
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 | # DATA_PLT - .plt should be in data segment, not text segment. | |
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 | test -z "$ENTRY" && ENTRY=_start | |
24 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
25 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
26 | test "$LD_FLAG" = "N" && DATA_ADDR=. | |
c56c9218 C |
27 | SBSS2=".sbss2 ${RELOCATING-0} : { *(.sbss2) }" |
28 | SDATA2=".sdata2 ${RELOCATING-0} : { *(.sdata2) }" | |
29 | INTERP=".interp ${RELOCATING-0} : { *(.interp) }" | |
30 | PLT=".plt ${RELOCATING-0} : { *(.plt) }" | |
5f16938d MM |
31 | cat <<EOF |
32 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", | |
33 | "${LITTLE_OUTPUT_FORMAT}") | |
34 | OUTPUT_ARCH(${ARCH}) | |
35 | ENTRY(${ENTRY}) | |
36 | ||
37 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
38 | ${RELOCATING+/* Do we need any of these for elf? | |
39 | __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} | |
40 | ${RELOCATING+${EXECUTABLE_SYMBOLS}} | |
41 | ${RELOCATING- /* For some reason, the Solaris linker makes bad executables | |
42 | if gld -r is used and the intermediate file has sections starting | |
43 | at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld | |
44 | bug. But for now assigning the zero vmas works. */} | |
fb2a7661 MM |
45 | |
46 | ${RELOCATING+PROVIDE (__stack = 0);} | |
5f16938d MM |
47 | SECTIONS |
48 | { | |
49 | /* Read-only sections, merged into text segment: */ | |
50 | ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}} | |
51 | ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} | |
52 | ${CREATE_SHLIB-${INTERP}} | |
be03dc3e MM |
53 | .hash ${RELOCATING-0} : { *(.hash) } |
54 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
55 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
56 | .rela.text ${RELOCATING-0} : { *(.rela.text) } | |
57 | .rela.data ${RELOCATING-0} : { *(.rela.data) } | |
58 | .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } | |
59 | .rela.got ${RELOCATING-0} : { *(.rela.got) } | |
be03dc3e MM |
60 | .rela.got1 ${RELOCATING-0} : { *(.rela.got1) } |
61 | .rela.got2 ${RELOCATING-0} : { *(.rela.got2) } | |
62 | .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } | |
63 | .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } | |
64 | .rela.init ${RELOCATING-0} : { *(.rela.init) } | |
65 | .rela.fini ${RELOCATING-0} : { *(.rela.fini) } | |
66 | .rela.bss ${RELOCATING-0} : { *(.rela.bss) } | |
67 | .rela.plt ${RELOCATING-0} : { *(.rela.plt) } | |
c2b6884b MM |
68 | .rela.sdata ${RELOCATING-0} : { *(.rela.sdata2) } |
69 | .rela.sbss ${RELOCATING-0} : { *(.rela.sbss2) } | |
70 | .rela.sdata2 ${RELOCATING-0} : { *(.rela.sdata2) } | |
71 | .rela.sbss2 ${RELOCATING-0} : { *(.rela.sbss2) } | |
5f16938d MM |
72 | ${DATA_PLT-${PLT}} |
73 | .text ${RELOCATING-0} : | |
74 | { | |
75 | ${RELOCATING+${TEXT_START_SYMBOLS}} | |
76 | *(.text) | |
77 | /* .gnu.warning sections are handled specially by elf32.em. */ | |
78 | *(.gnu.warning) | |
79 | } =${NOP-0} | |
28ad0357 MM |
80 | .init ${RELOCATING-0} : { *(.init) } =${NOP-0} |
81 | .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} | |
c2b6884b MM |
82 | .rodata ${RELOCATING-0} : { *(.rodata) } |
83 | .rodata1 ${RELOCATING-0} : { *(.rodata1) } | |
28ad0357 MM |
84 | ${RELOCATING+_etext = .;} |
85 | ${RELOCATING+PROVIDE (etext = .);} | |
c56c9218 C |
86 | ${CREATE_SHLIB-${SDATA2}} |
87 | ${CREATE_SHLIB-${SBSS2}} | |
5f16938d MM |
88 | ${RELOCATING+${OTHER_READONLY_SECTIONS}} |
89 | ||
c2b6884b MM |
90 | /* Adjust the address for the data segment. We want to adjust up to |
91 | the same address within the page on the next page up. It would | |
92 | be more correct to do this: | |
93 | ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (ALIGN(8) & (${MAXPAGESIZE} - 1))};} | |
94 | The current expression does not correctly handle the case of a | |
95 | text segment ending precisely at the end of a page; it causes the | |
96 | data segment to skip a page. The above expression does not have | |
97 | this problem, but it will currently (2/95) cause BFD to allocate | |
98 | a single segment, combining both text and data, for this case. | |
99 | This will prevent the text segment from being shared among | |
100 | multiple executions of the program; I think that is more | |
101 | important than losing a page of the virtual address space (note | |
102 | that no actual memory is lost; the page which is skipped can not | |
103 | be referenced). */ | |
5f16938d | 104 | ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};} |
c2b6884b | 105 | |
5f16938d MM |
106 | .data ${RELOCATING-0} : |
107 | { | |
108 | ${RELOCATING+${DATA_START_SYMBOLS}} | |
109 | *(.data) | |
110 | ${CONSTRUCTING+CONSTRUCTORS} | |
111 | } | |
112 | .data1 ${RELOCATING-0} : { *(.data1) } | |
113 | ${RELOCATING+${OTHER_READWRITE_SECTIONS}} | |
5f16938d | 114 | |
4fe13b2b MM |
115 | .got1 ${RELOCATING-0} : { *(.got1) } |
116 | .dynamic ${RELOCATING-0} : { *(.dynamic) } | |
dd0f9635 | 117 | |
86d0248d | 118 | /* Put .ctors and .dtors next to the .got2 section, so that the pointers |
4fe13b2b MM |
119 | get relocated with -mrelocatable. Also put in the .fixup pointers. |
120 | The current compiler no longer needs this, but keep it around for 2.7.2 */ | |
86d0248d | 121 | |
4d99a950 | 122 | ${RELOCATING+PROVIDE (_GOT2_START_ = .);} |
4fe13b2b MM |
123 | .got2 ${RELOCATING-0} : { *(.got2) } |
124 | ||
4d99a950 | 125 | ${RELOCATING+PROVIDE (__CTOR_LIST__ = .);} |
4fe13b2b | 126 | .ctors ${RELOCATING-0} : { *(.ctors) } |
4d99a950 | 127 | ${RELOCATING+PROVIDE (__CTOR_END__ = .);} |
4fe13b2b | 128 | |
4d99a950 | 129 | ${RELOCATING+PROVIDE (__DTOR_LIST__ = .);} |
4fe13b2b | 130 | .dtors ${RELOCATING-0} : { *(.dtors) } |
4d99a950 | 131 | ${RELOCATING+PROVIDE (__DTOR_END__ = .);} |
4fe13b2b | 132 | |
4d99a950 | 133 | ${RELOCATING+PROVIDE (_FIXUP_START_ = .);} |
4fe13b2b | 134 | .fixup ${RELOCATING-0} : { *(.fixup) } |
4d99a950 MM |
135 | ${RELOCATING+PROVIDE (_FIXUP_END_ = .);} |
136 | ${RELOCATING+PROVIDE (_GOT2_END_ = .);} | |
4fe13b2b | 137 | |
4d99a950 | 138 | ${RELOCATING+PROVIDE (_GOT_START_ = .);} |
4fe13b2b MM |
139 | .got ${RELOCATING-0} : { *(.got) } |
140 | .got.plt ${RELOCATING-0} : { *(.got.plt) } | |
c56c9218 C |
141 | ${CREATE_SHLIB+${SDATA2}} |
142 | ${CREATE_SHLIB+${SBSS2}} | |
4d99a950 | 143 | ${RELOCATING+PROVIDE (_GOT_END_ = .);} |
1e4b4b1c | 144 | |
5f16938d MM |
145 | ${DATA_PLT+${PLT}} |
146 | /* We want the small data sections together, so single-instruction offsets | |
147 | can access them all, and initialized data all before uninitialized, so | |
148 | we can shorten the on-disk segment size. */ | |
4d99a950 | 149 | .sdata ${RELOCATING-0} : { *(.sdata) } |
5f16938d MM |
150 | ${RELOCATING+_edata = .;} |
151 | ${RELOCATING+PROVIDE (edata = .);} | |
7453a753 MM |
152 | .sbss ${RELOCATING-0} : |
153 | { | |
4d99a950 | 154 | ${RELOCATING+PROVIDE (__sbss_start = .);} |
7453a753 MM |
155 | *(.sbss) |
156 | *(.scommon) | |
4d99a950 | 157 | ${RELOCATING+PROVIDE (__sbss_end = .);} |
7453a753 | 158 | } |
5f16938d MM |
159 | .bss ${RELOCATING-0} : |
160 | { | |
7453a753 | 161 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} |
4d99a950 | 162 | ${RELOCATING+PROVIDE (__bss_start = .);} |
5f16938d MM |
163 | *(.dynbss) |
164 | *(.bss) | |
165 | *(COMMON) | |
166 | } | |
167 | ${RELOCATING+_end = . ;} | |
168 | ${RELOCATING+PROVIDE (end = .);} | |
169 | ||
170 | /* These are needed for ELF backends which have not yet been | |
171 | converted to the new style linker. */ | |
172 | .stab 0 : { *(.stab) } | |
173 | .stabstr 0 : { *(.stabstr) } | |
174 | ||
c2b6884b MM |
175 | /* DWARF debug sections. |
176 | Symbols in the .debug DWARF section are relative to the beginning of the | |
177 | section so we begin .debug at 0. It's not clear yet what needs to happen | |
178 | for the others. */ | |
179 | .debug 0 : { *(.debug) } | |
180 | .debug_srcinfo 0 : { *(.debug_srcinfo) } | |
181 | .debug_aranges 0 : { *(.debug_aranges) } | |
182 | .debug_pubnames 0 : { *(.debug_pubnames) } | |
183 | .debug_sfnames 0 : { *(.debug_sfnames) } | |
184 | .line 0 : { *(.line) } | |
185 | ||
5f16938d MM |
186 | /* These must appear regardless of ${RELOCATING}. */ |
187 | ${OTHER_SECTIONS} | |
188 | } | |
189 | EOF |