1# $MirOS: src/gnu/usr.bin/binutils/ld/scripttempl/i386beos.sc,v 1.3 2009/10/04 03:03:05 tg Exp $
2#
3# Linker script for PE.
4
5if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
6  RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
7fi
8
9# We can't easily and portably get an unquoted $ in a shell
10# substitution, so we do this instead.
11if test "${RELOCATING}"; then
12  R_TEXT='*(.text$*)'
13  R_DATA='*(.data$*)'
14  R_RDATA='*(.rdata$*)'
15  R_IDATA='
16    *(.idata$2)
17    *(.idata$3)
18    /* These zeroes mark the end of the import list.  */
19    LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
20    *(.idata$4)
21    *(.idata$5)
22    *(.idata$6)
23    *(.idata$7)'
24  R_CRT='*(.CRT$*)'
25  R_RSRC='*(.rsrc$*)'
26  R_EXC='*(.exc$*)'
27else
28  R_TEXT=
29  R_DATA=
30  R_RDATA=
31  R_IDATA=
32  R_CRT=
33  R_RSRC=
34  R_EXC=
35fi
36
37cat <<EOF
38${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
39${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
40
41${LIB_SEARCH_DIRS}
42
43ENTRY(__start)
44${RELOCATING+header = .;}
45${RELOCATING+__fltused = .; /* set up floating pt for MS .obj\'s */}
46${RELOCATING+__ldused = .;}
47SECTIONS
48{
49  .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
50  {
51    ${RELOCATING+ __text_start__ = . ;}
52    ${RELOCATING+ *(.init)}
53    *(.text)
54    ${R_TEXT}
55    *(.glue_7t)
56    *(.glue_7)
57    ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
58			LONG (-1); *(.ctors); *(.ctor); LONG (0); }
59    ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
60			LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
61    ${RELOCATING+ *(.fini)}
62    /* ??? Why is .gcc_exc here?  */
63    ${RELOCATING+ *(.gcc_exc)}
64    ${RELOCATING+ etext = .;}
65    ${RELOCATING+ __text_end__ = .;}
66    *(.gcc_except_table)
67  }
68
69  /* The Cygwin32 library uses a section to avoid copying certain data
70     on fork.  This used to be named ".data\$nocopy".  The linker used
71     to include this between __data_start__ and __data_end__, but that
72     breaks building the cygwin32 dll.  Instead, we name the section
73     ".data_cygwin_nocopy" and explictly include it after __data_end__. */
74
75  .data ${RELOCATING+BLOCK(__section_alignment__)} :
76  {
77    ${RELOCATING+__data_start__ = . ;}
78    *(.data)
79    *(.data2)
80    ${R_DATA}
81    ${RELOCATING+__data_end__ = . ;}
82    ${RELOCATING+*(.data_cygwin_nocopy)}
83  }
84
85  .bss ${RELOCATING+BLOCK(__section_alignment__)} :
86  {
87    ${RELOCATING+__bss_start__ = . ;}
88    *(.bss)
89    *(COMMON)
90    /* link.exe apparently pulls in .obj's because of UNDEF common
91	symbols, which is not the coff way, but that's MS for you. */
92    *(.CRT\$XCA)
93    *(.CRT\$XCZ)
94    *(.CRT\$XIA)
95    *(.CRT\$XIZ)
96    ${RELOCATING+__bss_end__ = . ;}
97  }
98
99  .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
100  {
101    *(.rdata)
102    ${R_RDATA}
103    *(.eh_frame)
104  }
105
106  .edata ${RELOCATING+BLOCK(__section_alignment__)} :
107  {
108    *(.edata)
109  }
110
111  /DISCARD/ :
112  {
113    *(.debug\$S)
114    *(.debug\$T)
115    *(.debug\$F)
116    *(.drectve)
117    *(.debug*)
118  }
119
120  .idata ${RELOCATING+BLOCK(__section_alignment__)} :
121  {
122    /* This cannot currently be handled with grouped sections.
123	See pe.em:sort_sections.  */
124    ${R_IDATA}
125  }
126  .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
127  {
128    ${R_CRT}
129  }
130
131  .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
132  {
133    /* end is deprecated, don't use it */
134    ${RELOCATING+ end = .;}
135    ${RELOCATING+ _end = .;}
136    ${RELOCATING+ __end__ = .;}
137  }
138
139  .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
140  {
141    *(.reloc)
142  }
143
144  .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
145  {
146    *(.rsrc)
147    ${R_RSRC}
148  }
149
150  .exc ${RELOCATING+BLOCK(__section_alignment__)} :
151  {
152    *(.exc)
153    ${R_EXC}
154  }
155
156  .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+\(NOLOAD\)} :
157  {
158    [ .stab ]
159  }
160
161  .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+\(NOLOAD\)} :
162  {
163    [ .stabstr ]
164  }
165  /* DWARF debug sections.
166     Symbols in the DWARF debugging sections are relative to the beginning
167     of the section so we begin them at 0.  */
168
169  /* DWARF 1 */
170  .debug          0 ${RELOCATING+\(NOLOAD\)} : { *(.debug) }
171  .line           0 ${RELOCATING+\(NOLOAD\)} : { *(.line) }
172
173  /* GNU DWARF 1 extensions */
174  .debug_srcinfo  0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_srcinfo) }
175  .debug_sfnames  0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_sfnames) }
176
177  /* DWARF 1.1 and DWARF 2 */
178  .debug_aranges  0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_aranges) }
179  .debug_pubnames 0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_pubnames) }
180
181  /* DWARF 2 */
182  .debug_info     0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_info) *(.gnu.linkonce.wi.*) }
183  .debug_abbrev   0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_abbrev) }
184  .debug_line     0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_line) }
185  .debug_frame    0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_frame) }
186  .debug_str      0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_str) }
187  .debug_loc      0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_loc) }
188  .debug_macinfo  0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_macinfo) }
189
190  /* SGI/MIPS DWARF 2 extensions */
191  .debug_weaknames 0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_weaknames) }
192  .debug_funcnames 0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_funcnames) }
193  .debug_typenames 0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_typenames) }
194  .debug_varnames  0 ${RELOCATING+\(NOLOAD\)} : { *(.debug_varnames) }
195}
196EOF
197