1# Linker script for MCore 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 R_DATA='*(SORT(.data$*))' 17 R_RDATA='*(SORT(.rdata$*))' 18 R_IDATA=' 19 SORT(*)(.idata$2) 20 SORT(*)(.idata$3) 21 /* These zeroes mark the end of the import list. */ 22 LONG (0); LONG (0); LONG (0); LONG (0); LONG (0); 23 SORT(*)(.idata$4) 24 SORT(*)(.idata$5) 25 SORT(*)(.idata$6) 26 SORT(*)(.idata$7)' 27 R_CRT='*(SORT(.CRT$*))' 28 R_RSRC='*(SORT(.rsrc$*))' 29else 30 R_TEXT= 31 R_DATA= 32 R_RDATA= 33 R_IDATA= 34 R_CRT= 35 R_RSRC= 36fi 37 38if test "$RELOCATING"; then 39 # Can't use ${RELOCATING+blah "blah" blah} for this, 40 # because bash 2.x will lose the doublequotes. 41 cat <<EOF 42OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", 43 "${LITTLE_OUTPUT_FORMAT}") 44EOF 45fi 46 47cat <<EOF 48${LIB_SEARCH_DIRS} 49 50ENTRY(_mainCRTStartup) 51 52SECTIONS 53{ 54 .text ${RELOCATING+ __image_base__ + __section_alignment__ } : 55 { 56 ${RELOCATING+ *(.init)} 57 *(.text) 58 ${R_TEXT} 59 *(.glue_7t) 60 *(.glue_7) 61 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 62 LONG (-1); *(.ctors); *(.ctor); LONG (0); } 63 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 64 LONG (-1); *(.dtors); *(.dtor); LONG (0); } 65 ${RELOCATING+ *(.fini)} 66 /* ??? Why is .gcc_exc here? */ 67 ${RELOCATING+ *(.gcc_exc)} 68 ${RELOCATING+ etext = .;} 69 *(.gcc_except_table) 70 } 71 72 /* The Cygwin32 library uses a section to avoid copying certain data 73 on fork. This used to be named ".data$nocopy". The linker used 74 to include this between __data_start__ and __data_end__, but that 75 breaks building the cygwin32 dll. Instead, we name the section 76 ".data_cygwin_nocopy" and explictly include it after __data_end__. */ 77 78 .data ${RELOCATING+BLOCK(__section_alignment__)} : 79 { 80 ${RELOCATING+__data_start__ = . ;} 81 *(.data) 82 *(.data2) 83 ${R_DATA} 84 ${RELOCATING+__data_end__ = . ;} 85 ${RELOCATING+*(.data_cygwin_nocopy)} 86 } 87 88 .bss ${RELOCATING+BLOCK(__section_alignment__)} : 89 { 90 ${RELOCATING+__bss_start__ = . ;} 91 *(.bss) 92 *(COMMON) 93 ${RELOCATING+__bss_end__ = . ;} 94 } 95 96 .rdata ${RELOCATING+BLOCK(__section_alignment__)} : 97 { 98 *(.rdata) 99 ${R_RDATA} 100 *(.eh_frame) 101 } 102 103 .edata ${RELOCATING+BLOCK(__section_alignment__)} : 104 { 105 *(.edata) 106 } 107 108 /DISCARD/ : 109 { 110 *(.debug\$S) 111 *(.debug\$T) 112 *(.debug\$F) 113 *(.drectve) 114 } 115 116 .idata ${RELOCATING+BLOCK(__section_alignment__)} : 117 { 118 /* This cannot currently be handled with grouped sections. 119 See pe.em:sort_sections. */ 120 ${R_IDATA} 121 } 122 .CRT ${RELOCATING+BLOCK(__section_alignment__)} : 123 { 124 ${R_CRT} 125 } 126 127 .endjunk ${RELOCATING+BLOCK(__section_alignment__)} : 128 { 129 /* end is deprecated, don't use it */ 130 ${RELOCATING+ end = .;} 131 ${RELOCATING+ _end = .;} 132 ${RELOCATING+ __end__ = .;} 133 } 134 135 .reloc ${RELOCATING+BLOCK(__section_alignment__)} : 136 { 137 *(.reloc) 138 } 139 140 .rsrc ${RELOCATING+BLOCK(__section_alignment__)} : 141 { 142 *(.rsrc) 143 ${R_RSRC} 144 } 145 146 .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 147 { 148 [ .stab ] 149 } 150 151 .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} : 152 { 153 [ .stabstr ] 154 } 155 156 .stack 0x80000 : 157 { 158 _stack = .; 159 *(.stack) 160 } 161} 162EOF 163