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
16 # DATA_START_SYMBOLS - symbols that appear at the start of the
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.
28 # When adding sections, do note that the names of some sections are used
29 # when specifying the start address of the next.
32 test -z "$ENTRY" && ENTRY=_start
33 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
34 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
35 if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi
36 test -z "${ELFSIZE}" && ELFSIZE=32
37 test "$LD_FLAG" = "N" && DATA_ADDR=.
38 INTERP=".interp ${RELOCATING-0} : { *(.interp) }"
39 PLT=".plt ${RELOCATING-0} : { *(.plt) }"
40 DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
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"
46 test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
50 OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
51 "${LITTLE_OUTPUT_FORMAT}")
52 OUTPUT_ARCH(${OUTPUT_ARCH})
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. */}
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}
105 .text ${RELOCATING-0} :
107 ${RELOCATING+${TEXT_START_SYMBOLS}}
110 /* .gnu.warning sections are handled specially by elf32.em. */
112 ${RELOCATING+*(.gnu.linkonce.t*)}
113 ${RELOCATING+${OTHER_TEXT_SECTIONS}}
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}}
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))};}}
127 .data ${RELOCATING-0} :
129 ${RELOCATING+${DATA_START_SYMBOLS}}
131 ${RELOCATING+*(.gnu.linkonce.d*)}
132 ${CONSTRUCTING+CONSTRUCTORS}
134 .data1 ${RELOCATING-0} : { *(.data1) }
135 ${RELOCATING+${OTHER_READWRITE_SECTIONS}}
136 .ctors ${RELOCATING-0} :
138 ${CONSTRUCTING+${CTOR_START}}
141 ${CONSTRUCTING+${CTOR_END}}
143 .dtors ${RELOCATING-0} :
145 ${CONSTRUCTING+${DTOR_START}}
148 ${CONSTRUCTING+${DTOR_END}}
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} :
170 ${RELOCATING+. = ALIGN(${ELFSIZE} / 8);}
171 ${RELOCATING+_end = . ;}
172 ${RELOCATING+PROVIDE (end = .);}
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) }
182 .comment 0 : { *(.comment) }
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. */
189 .debug 0 : { *(.debug) }
190 .line 0 : { *(.line) }
192 /* GNU DWARF 1 extensions */
193 .debug_srcinfo 0 : { *(.debug_srcinfo) }
194 .debug_sfnames 0 : { *(.debug_sfnames) }
196 /* DWARF 1.1 and DWARF 2 */
197 .debug_aranges 0 : { *(.debug_aranges) }
198 .debug_pubnames 0 : { *(.debug_pubnames) }
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) }
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) }
215 ${RELOCATING+${OTHER_RELOCATING_SECTIONS}}
217 /* These must appear regardless of ${RELOCATING}. */