LD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies
[external/binutils.git] / ld / scripttempl / i386beos.sc
1 # Linker script for PE.
2 #
3 # Copyright (C) 2014-2019 Free Software Foundation, Inc.
4 #
5 # Copying and distribution of this file, with or without modification,
6 # are permitted in any medium without royalty provided the copyright
7 # notice and this notice are preserved.
8
9 if test -z "${RELOCATEABLE_OUTPUT_FORMAT}"; then
10   RELOCATEABLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
11 fi
12
13 # We can't easily and portably get an unquoted $ in a shell
14 # substitution, so we do this instead.
15 if test "${RELOCATING}"; then
16   R_TEXT='*(.text$*)'
17   R_DATA='*(.data$*)'
18   R_RDATA='*(.rdata$*)'
19   R_IDATA='
20     *(.idata$2)
21     *(.idata$3)
22     /* These zeroes mark the end of the import list.  */
23     LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
24     *(.idata$4)
25     *(.idata$5)
26     *(.idata$6)
27     *(.idata$7)'
28   R_CRT='*(.CRT$*)'
29   R_RSRC='*(.rsrc$*)'
30   R_EXC='*(.exc$*)'
31 else
32   R_TEXT=
33   R_DATA=
34   R_RDATA=
35   R_IDATA=
36   R_CRT=
37   R_RSRC=
38   R_EXC=
39 fi
40
41 cat <<EOF
42 /* Copyright (C) 2014-2019 Free Software Foundation, Inc.
43
44    Copying and distribution of this script, with or without modification,
45    are permitted in any medium without royalty provided the copyright
46    notice and this notice are preserved.  */
47
48 ${RELOCATING+OUTPUT_FORMAT(${OUTPUT_FORMAT})}
49 ${RELOCATING-OUTPUT_FORMAT(${RELOCATEABLE_OUTPUT_FORMAT})}
50
51 ${LIB_SEARCH_DIRS}
52
53 ${RELOCATING+ENTRY (__start)}
54 ${RELOCATING+header = .;}
55 ${RELOCATING+__fltused = .; /* set up floating pt for MS .obj\'s */}
56 ${RELOCATING+__ldused = .;}
57 SECTIONS
58 {
59   .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
60   {
61     ${RELOCATING+ __text_start__ = . ;}
62     ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
63     *(.text)
64     ${R_TEXT}
65     *(.glue_7t)
66     *(.glue_7)
67     ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
68                         LONG (-1); *(.ctors); *(.ctor); LONG (0); }
69     ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
70                         LONG (-1); *(.dtors); *(.dtor);  LONG (0); }
71     ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
72     /* ??? Why is .gcc_exc here?  */
73     ${RELOCATING+ *(.gcc_exc)}
74     ${RELOCATING+ etext = .;}
75     ${RELOCATING+ __text_end__ = .;}
76     *(.gcc_except_table)
77   }
78
79   /* The Cygwin32 library uses a section to avoid copying certain data
80      on fork.  This used to be named ".data$nocopy".  The linker used
81      to include this between __data_start__ and __data_end__, but that
82      breaks building the cygwin32 dll.  Instead, we name the section
83      ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
84
85   .data ${RELOCATING+BLOCK(__section_alignment__)} :
86   {
87     ${RELOCATING+__data_start__ = . ;}
88     *(.data)
89     *(.data2)
90     ${R_DATA}
91     ${RELOCATING+__data_end__ = . ;}
92     ${RELOCATING+*(.data_cygwin_nocopy)}
93   }
94
95   .bss ${RELOCATING+BLOCK(__section_alignment__)} :
96   {
97     ${RELOCATING+__bss_start__ = . ;}
98     *(.bss)
99     *(COMMON)
100     /* link.exe apparently pulls in .obj's because of UNDEF common
101         symbols, which is not the coff way, but that's MS for you. */
102     *(.CRT\$XCA)
103     *(.CRT\$XCZ)
104     *(.CRT\$XIA)
105     *(.CRT\$XIZ)
106     ${RELOCATING+__bss_end__ = . ;}
107   }
108
109   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
110   {
111     *(.rdata)
112     ${R_RDATA}
113     *(.eh_frame)
114   }
115
116   .edata ${RELOCATING+BLOCK(__section_alignment__)} :
117   {
118     *(.edata)
119   }
120
121   /DISCARD/ :
122   {
123     *(.debug\$S)
124     *(.debug\$T)
125     *(.debug\$F)
126     *(.drectve)
127     *(.debug*)
128   }
129
130   .idata ${RELOCATING+BLOCK(__section_alignment__)} :
131   {
132     /* This cannot currently be handled with grouped sections.
133         See pe.em:sort_sections.  */
134     ${R_IDATA}
135   }
136   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
137   {
138     ${R_CRT}
139   }
140
141   .endjunk ${RELOCATING+BLOCK(__section_alignment__)} :
142   {
143     /* end is deprecated, don't use it */
144     ${RELOCATING+ end = .;}
145     ${RELOCATING+ _end = .;}
146     ${RELOCATING+ __end__ = .;}
147   }
148
149   .reloc ${RELOCATING+BLOCK(__section_alignment__)} :
150   {
151     *(.reloc)
152   }
153
154   .rsrc ${RELOCATING+BLOCK(__section_alignment__)} :
155   {
156     *(.rsrc)
157     ${R_RSRC}
158   }
159
160   .exc ${RELOCATING+BLOCK(__section_alignment__)} :
161   {
162     *(.exc)
163     ${R_EXC}
164   }
165
166   .stab ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
167   {
168     [ .stab ]
169   }
170
171   .stabstr ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
172   {
173     [ .stabstr ]
174   }
175 EOF
176
177 . $srcdir/scripttempl/DWARF.sc
178
179 cat <<EOF
180 }
181 EOF