Commit | Line | Data |
---|---|---|
267a3ab3 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 | |
26c7ca95 | 5 | # INITIAL_READONLY_SECTIONS - at start of text segment |
fa247c00 | 6 | # OTHER_READONLY_SECTIONS - other than .text .init .rodata ... |
267a3ab3 | 7 | # (e.g., .PARISC.milli) |
26c7ca95 | 8 | # OTHER_TEXT_SECTIONS - these get put in .text when relocating |
fa247c00 | 9 | # OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... |
267a3ab3 | 10 | # (e.g., .PARISC.global) |
31ddb156 | 11 | # OTHER_SECTIONS - at the end |
267a3ab3 ILT |
12 | # EXECUTABLE_SYMBOLS - symbols that must be defined for an |
13 | # executable (e.g., _DYNAMIC_LINK) | |
2a9fa50c ILT |
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. | |
26c7ca95 ILT |
18 | # OTHER_GOT_SYMBOLS - symbols defined just before .got. |
19 | # OTHER_GOT_SECTIONS - sections just after .got and .sdata. | |
bff600cf ILT |
20 | # OTHER_BSS_SYMBOLS - symbols that appear at the start of the |
21 | # .bss section besides __bss_start. | |
2a9fa50c | 22 | # DATA_PLT - .plt should be in data segment, not text segment. |
26c7ca95 | 23 | # TEXT_DYNAMIC - .dynamic in text segment, not data segment. |
3d046499 | 24 | # EMBEDDED - whether this is for an embedded system. |
26c7ca95 ILT |
25 | # SHLIB_TEXT_START_ADDR - if set, add to SIZEOF_HEADERS to set |
26 | # start address of shared library. | |
267a3ab3 ILT |
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 | # | |
26c7ca95 | 31 | |
fa247c00 | 32 | test -z "$ENTRY" && ENTRY=_start |
cd1d4f83 ILT |
33 | test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} |
34 | test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} | |
18f0961e | 35 | if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi |
26c7ca95 | 36 | test -z "${ELFSIZE}" && ELFSIZE=32 |
cd1d4f83 | 37 | test "$LD_FLAG" = "N" && DATA_ADDR=. |
31ddb156 | 38 | INTERP=".interp ${RELOCATING-0} : { *(.interp) }" |
2a9fa50c | 39 | PLT=".plt ${RELOCATING-0} : { *(.plt) }" |
26c7ca95 | 40 | DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" |
3d046499 ILT |
41 | |
42 | # if this is for an embedded system, don't add SIZEOF_HEADERS. | |
43 | if [ -z "$EMBEDDED" ]; then | |
44 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" | |
45 | else | |
46 | test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" | |
47 | fi | |
48 | ||
f90bb826 | 49 | cat <<EOF |
cd1d4f83 ILT |
50 | OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", |
51 | "${LITTLE_OUTPUT_FORMAT}") | |
18f0961e | 52 | OUTPUT_ARCH(${OUTPUT_ARCH}) |
fa247c00 | 53 | ENTRY(${ENTRY}) |
f90bb826 KR |
54 | |
55 | ${RELOCATING+${LIB_SEARCH_DIRS}} | |
267a3ab3 ILT |
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. */} | |
f90bb826 KR |
63 | SECTIONS |
64 | { | |
267a3ab3 | 65 | /* Read-only sections, merged into text segment: */ |
3d046499 | 66 | ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} |
26c7ca95 | 67 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}} |
31ddb156 | 68 | ${CREATE_SHLIB-${INTERP}} |
26c7ca95 ILT |
69 | ${INITIAL_READONLY_SECTIONS} |
70 | ${TEXT_DYNAMIC+${DYNAMIC}} | |
cd1d4f83 ILT |
71 | .hash ${RELOCATING-0} : { *(.hash) } |
72 | .dynsym ${RELOCATING-0} : { *(.dynsym) } | |
73 | .dynstr ${RELOCATING-0} : { *(.dynstr) } | |
3d046499 ILT |
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} : | |
26c7ca95 | 78 | { *(.rel.text) ${RELOCATING+*(.rel.gnu.linkonce.t*)} } |
3d046499 | 79 | .rela.text ${RELOCATING-0} : |
26c7ca95 | 80 | { *(.rela.text) ${RELOCATING+*(.rela.gnu.linkonce.t*)} } |
3d046499 | 81 | .rel.data ${RELOCATING-0} : |
26c7ca95 | 82 | { *(.rel.data) ${RELOCATING+*(.rel.gnu.linkonce.d*)} } |
3d046499 | 83 | .rela.data ${RELOCATING-0} : |
26c7ca95 | 84 | { *(.rela.data) ${RELOCATING+*(.rela.gnu.linkonce.d*)} } |
3d046499 | 85 | .rel.rodata ${RELOCATING-0} : |
26c7ca95 | 86 | { *(.rel.rodata) ${RELOCATING+*(.rel.gnu.linkonce.r*)} } |
3d046499 | 87 | .rela.rodata ${RELOCATING-0} : |
26c7ca95 | 88 | { *(.rela.rodata) ${RELOCATING+*(.rela.gnu.linkonce.r*)} } |
cd1d4f83 ILT |
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} | |
2a9fa50c ILT |
104 | ${DATA_PLT-${PLT}} |
105 | .text ${RELOCATING-0} : | |
f90bb826 | 106 | { |
2a9fa50c | 107 | ${RELOCATING+${TEXT_START_SYMBOLS}} |
f90bb826 | 108 | *(.text) |
26c7ca95 | 109 | *(.stub) |
fa247c00 ILT |
110 | /* .gnu.warning sections are handled specially by elf32.em. */ |
111 | *(.gnu.warning) | |
26c7ca95 ILT |
112 | ${RELOCATING+*(.gnu.linkonce.t*)} |
113 | ${RELOCATING+${OTHER_TEXT_SECTIONS}} | |
fa247c00 | 114 | } =${NOP-0} |
2a9fa50c | 115 | ${RELOCATING+_etext = .;} |
31ddb156 | 116 | ${RELOCATING+PROVIDE (etext = .);} |
2a9fa50c | 117 | .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} |
26c7ca95 | 118 | .rodata ${RELOCATING-0} : { *(.rodata) ${RELOCATING+*(.gnu.linkonce.r*)} } |
2a9fa50c | 119 | .rodata1 ${RELOCATING-0} : { *(.rodata1) } |
267a3ab3 | 120 | ${RELOCATING+${OTHER_READONLY_SECTIONS}} |
267a3ab3 | 121 | |
18f0961e ILT |
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. */ | |
26c7ca95 ILT |
124 | ${CREATE_SHLIB-${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} |
125 | ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};}} | |
18f0961e | 126 | |
2a9fa50c | 127 | .data ${RELOCATING-0} : |
f90bb826 | 128 | { |
2a9fa50c | 129 | ${RELOCATING+${DATA_START_SYMBOLS}} |
f90bb826 | 130 | *(.data) |
26c7ca95 | 131 | ${RELOCATING+*(.gnu.linkonce.d*)} |
f90bb826 | 132 | ${CONSTRUCTING+CONSTRUCTORS} |
f90bb826 | 133 | } |
2a9fa50c | 134 | .data1 ${RELOCATING-0} : { *(.data1) } |
267a3ab3 | 135 | ${RELOCATING+${OTHER_READWRITE_SECTIONS}} |
3d046499 ILT |
136 | .ctors ${RELOCATING-0} : |
137 | { | |
138 | ${CONSTRUCTING+${CTOR_START}} | |
26c7ca95 | 139 | *(SORT(.ctors.*)) |
3d046499 ILT |
140 | *(.ctors) |
141 | ${CONSTRUCTING+${CTOR_END}} | |
142 | } | |
143 | .dtors ${RELOCATING-0} : | |
144 | { | |
145 | ${CONSTRUCTING+${DTOR_START}} | |
26c7ca95 | 146 | *(SORT(.dtors.*)) |
3d046499 ILT |
147 | *(.dtors) |
148 | ${CONSTRUCTING+${DTOR_END}} | |
149 | } | |
150 | ${DATA_PLT+${PLT}} | |
26c7ca95 | 151 | ${RELOCATING+${OTHER_GOT_SYMBOLS}} |
cd1d4f83 | 152 | .got ${RELOCATING-0} : { *(.got.plt) *(.got) } |
26c7ca95 | 153 | ${TEXT_DYNAMIC-${DYNAMIC}} |
267a3ab3 ILT |
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. */ | |
2a9fa50c | 157 | .sdata ${RELOCATING-0} : { *(.sdata) } |
26c7ca95 | 158 | ${RELOCATING+${OTHER_GOT_SECTIONS}} |
bff600cf | 159 | ${RELOCATING+_edata = .;} |
31ddb156 | 160 | ${RELOCATING+PROVIDE (edata = .);} |
2a9fa50c | 161 | ${RELOCATING+__bss_start = .;} |
bff600cf | 162 | ${RELOCATING+${OTHER_BSS_SYMBOLS}} |
2a9fa50c ILT |
163 | .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } |
164 | .bss ${RELOCATING-0} : | |
f90bb826 | 165 | { |
2a9fa50c | 166 | *(.dynbss) |
f90bb826 KR |
167 | *(.bss) |
168 | *(COMMON) | |
f90bb826 | 169 | } |
26c7ca95 | 170 | ${RELOCATING+. = ALIGN(${ELFSIZE} / 8);} |
2a9fa50c | 171 | ${RELOCATING+_end = . ;} |
31ddb156 ILT |
172 | ${RELOCATING+PROVIDE (end = .);} |
173 | ||
18f0961e | 174 | /* Stabs debugging sections. */ |
31ddb156 ILT |
175 | .stab 0 : { *(.stab) } |
176 | .stabstr 0 : { *(.stabstr) } | |
18f0961e ILT |
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. | |
3d046499 ILT |
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 */ | |
18f0961e | 189 | .debug 0 : { *(.debug) } |
3d046499 ILT |
190 | .line 0 : { *(.line) } |
191 | ||
192 | /* GNU DWARF 1 extensions */ | |
18f0961e | 193 | .debug_srcinfo 0 : { *(.debug_srcinfo) } |
3d046499 ILT |
194 | .debug_sfnames 0 : { *(.debug_sfnames) } |
195 | ||
196 | /* DWARF 1.1 and DWARF 2 */ | |
18f0961e ILT |
197 | .debug_aranges 0 : { *(.debug_aranges) } |
198 | .debug_pubnames 0 : { *(.debug_pubnames) } | |
3d046499 ILT |
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}} | |
31ddb156 ILT |
216 | |
217 | /* These must appear regardless of ${RELOCATING}. */ | |
218 | ${OTHER_SECTIONS} | |
f90bb826 KR |
219 | } |
220 | EOF |