1# Linker script for PE. 2 3if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then 4 RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} 5fi 6 7# We can't easily and portably get an unquoted $ in a shell 8# substitution, so we do this instead. 9# Sorting of the .foo$* sections is required by the definition of 10# grouped sections in PE. 11# Sorting of the file names in R_IDATA is required by the 12# current implementation of dlltool (this could probably be changed to 13# use grouped sections instead). 14if test "${RELOCATING}"; then 15 R_TEXT='*(SORT(.text$*))' 16 if test "x$LD_FLAG" = "xauto_import" ; then 17 R_DATA='*(SORT(.data$*)) 18 *(.rdata) 19 *(SORT(.rdata$*))' 20 R_RDATA='' 21 else 22 R_DATA='*(SORT(.data$*))' 23 R_RDATA='*(.rdata) 24 *(SORT(.rdata$*))' 25 fi 26 R_IDATA=' 27 SORT(*)(.idata$2) 28 SORT(*)(.idata$3) 29 /* These zeroes mark the end of the import list. */ 30 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); 31 SORT(*)(.idata$4) 32 SORT(*)(.idata$5) 33 SORT(*)(.idata$6) 34 SORT(*)(.idata$7)' 35 R_CRT_XC='*(SORT(.CRT$XC*)) /* C initialization */' 36 R_CRT_XI='*(SORT(.CRT$XI*)) /* C++ initialization */' 37 R_CRT_XL='*(SORT(.CRT$XL*)) /* TLS callbacks */' 38 R_CRT_XP='*(SORT(.CRT$XP*)) /* Pre-termination */' 39 R_CRT_XT='*(SORT(.CRT$XT*)) /* Termination */' 40 R_TLS=' 41 *(.tls) 42 *(.tls$) 43 *(SORT(.tls$*))' 44 R_RSRC='*(SORT(.rsrc$*))' 45else 46 R_TEXT= 47 R_DATA= 48 R_RDATA='*(.rdata)' 49 R_IDATA= 50 R_CRT= 51 R_RSRC= 52fi 53 54cat <<EOF 55${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})} 56${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})} 57${OUTPUT_ARCH+OUTPUT_ARCH(${OUTPUT_ARCH})} 58 59${LIB_SEARCH_DIRS} 60 61SECTIONS 62{ 63 ${RELOCATING+/* Make the virtual address and file offset synced if the alignment is} 64 ${RELOCATING+ lower than the target page size. */} 65 ${RELOCATING+. = SIZEOF_HEADERS;} 66 ${RELOCATING+. = ALIGN(__section_alignment__);} 67 .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} : 68 { 69 ${RELOCATING+ *(.init)} 70 *(.text) 71 ${R_TEXT} 72 *(.glue_7t) 73 *(.glue_7) 74 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 75 LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0); } 76 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 77 LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0); } 78 ${RELOCATING+ *(.fini)} 79 /* ??? Why is .gcc_exc here? */ 80 ${RELOCATING+ *(.gcc_exc)} 81 ${RELOCATING+PROVIDE (etext = .);} 82 ${RELOCATING+ *(.gcc_except_table)} 83 } 84 85 /* The Cygwin32 library uses a section to avoid copying certain data 86 on fork. This used to be named ".data$nocopy". The linker used 87 to include this between __data_start__ and __data_end__, but that 88 breaks building the cygwin32 dll. Instead, we name the section 89 ".data_cygwin_nocopy" and explictly include it after __data_end__. */ 90 91 .data ${RELOCATING+BLOCK(__section_alignment__)} : 92 { 93 ${RELOCATING+__data_start__ = . ;} 94 *(.data) 95 *(.data2) 96 ${R_DATA} 97 *(.jcr) 98 ${RELOCATING+__data_end__ = . ;} 99 ${RELOCATING+*(.data_cygwin_nocopy)} 100 } 101 102 .rdata ${RELOCATING+BLOCK(__section_alignment__)} : 103 { 104 ${R_RDATA} 105 ${RELOCATING+ *(.eh_frame)} 106 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;} 107 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;} 108 *(.rdata_runtime_pseudo_reloc) 109 ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} 110 ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;} 111 } 112 113 .pdata ${RELOCATING+BLOCK(__section_alignment__)} : 114 { 115 *(.pdata) 116 } 117 118 .bss ${RELOCATING+BLOCK(__section_alignment__)} : 119 { 120 ${RELOCATING+__bss_start__ = . ;} 121 *(.bss) 122 *(COMMON) 123 ${RELOCATING+__bss_end__ = . ;} 124 } 125 126 .edata ${RELOCATING+BLOCK(__section_alignment__)} : 127 { 128 *(.edata) 129 } 130 131 /DISCARD/ : 132 { 133 *(.debug\$S) 134 *(.debug\$T) 135 *(.debug\$F) 136 *(.drectve) 137 } 138 139 .idata ${RELOCATING+BLOCK(__section_alignment__)} : 140 { 141 /* This cannot currently be handled with grouped sections. 142 See pe.em:sort_sections. */ 143 ${R_IDATA} 144 } 145 .CRT ${RELOCATING+BLOCK(__section_alignment__)} : 146 { 147 ${RELOCATING+___crt_xc_start__ = . ;} 148 ${R_CRT_XC} 149 ${RELOCATING+___crt_xc_end__ = . ;} 150 ${RELOCATING+___crt_xi_start__ = . ;} 151 ${R_CRT_XI} 152 ${RELOCATING+___crt_xi_end__ = . ;} 153 ${RELOCATING+___crt_xl_start__ = . ;} 154 ${R_CRT_XL} 155 /* ___crt_xl_end__ is defined in the TLS Directory support code */ 156 ${RELOCATING+___crt_xp_start__ = . ;} 157 ${R_CRT_XP} 158 ${RELOCATING+___crt_xp_end__ = . ;} 159 ${RELOCATING+___crt_xt_start__ = . ;} 160 ${R_CRT_XT} 161 ${RELOCATING+___crt_xt_end__ = . ;} 162 } 163 164 .tls ${RELOCATING+BLOCK(__section_alignment__)} : 165 { 166 ${RELOCATING+___tls_start__ = . ;} 167 ${R_TLS} 168 ${RELOCATING+___tls_end__ = . ;} 169 } 170 171 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : 172 { 173 /* end is deprecated, don't use it */ 174 ${RELOCATING+PROVIDE (end = .);} 175 ${RELOCATING+PROVIDE ( _end = .);} 176 ${RELOCATING+ __end__ = .;} 177 } 178 179 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : 180 { 181 *(.rsrc) 182 ${R_RSRC} 183 } 184 185 .reloc ${RELOCATING+BLOCK(__section_alignment__)} : 186 { 187 *(.reloc) 188 } 189 190 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 191 { 192 *(.stab) 193 } 194 195 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 196 { 197 *(.stabstr) 198 } 199 200 /* DWARF debug sections. 201 Symbols in the DWARF debugging sections are relative to the beginning 202 of the section. Unlike other targets that fake this by putting the 203 section VMA at 0, the PE format will not allow it. */ 204 205 /* DWARF 1.1 and DWARF 2. */ 206 .debug_aranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 207 { 208 *(.debug_aranges) 209 } 210 211 .debug_pubnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 212 { 213 *(.debug_pubnames) 214 } 215 216 /* DWARF 2. */ 217 .debug_info ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 218 { 219 *(.debug_info) *(.gnu.linkonce.wi.*) 220 } 221 222 .debug_abbrev ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 223 { 224 *(.debug_abbrev) 225 } 226 227 .debug_line ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 228 { 229 *(.debug_line) 230 } 231 232 .debug_frame ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 233 { 234 *(.debug_frame) 235 } 236 237 .debug_str ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 238 { 239 *(.debug_str) 240 } 241 242 .debug_loc ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 243 { 244 *(.debug_loc) 245 } 246 247 .debug_macinfo ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 248 { 249 *(.debug_macinfo) 250 } 251 252 /* SGI/MIPS DWARF 2 extensions. */ 253 .debug_weaknames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 254 { 255 *(.debug_weaknames) 256 } 257 258 .debug_funcnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 259 { 260 *(.debug_funcnames) 261 } 262 263 .debug_typenames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 264 { 265 *(.debug_typenames) 266 } 267 268 .debug_varnames ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 269 { 270 *(.debug_varnames) 271 } 272 273 /* DWARF 3. */ 274 .debug_ranges ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 275 { 276 *(.debug_ranges) 277 } 278} 279EOF 280