1 # A PE linker script for PowerPC.
2 # Loosely based on Steve Chamberlain's pe.sc.
3 # All new mistakes should be credited to Kim Knuttila (krk@cygnus.com)
5 # These are substituted in as variables in order to get '}' in a shell
6 # conditional expansion.
7 INIT='.init : { *(.init) }'
8 FINI='.fini : { *(.fini) }'
10 OUTPUT_FORMAT(${OUTPUT_FORMAT})
13 /* Much of this layout was determined by delving into .exe files for
14 the box generated by other compilers/linkers/etc. This means that
15 if a particular feature did not happen to appear in one of the
16 subject files, then it may not be yet supported.
19 /* It's "mainCRTStartup", not "_mainCRTStartup", and it's located in
20 one of the two .lib files (libc.lib and kernel32.lib) that currently
21 must be present on the link line. This means that you must use
22 "-u mainCRTStartup" to make sure it gets included in the link.
25 ${RELOCATING+ENTRY (mainCRTStartup)}
30 /* text - the usual meaning */
31 .text ${RELOCATING+ __image_base__ + __section_alignment__ } :
33 ${RELOCATING+ *(.init);}
35 ${RELOCATING+ *(.text.*)}
37 ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
38 LONG (-1); *(.ctors); *(.ctor); LONG (0); }
39 ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
40 LONG (-1); *(.dtors); *(.dtor); LONG (0); }
41 ${RELOCATING+ *(.fini);}
42 ${RELOCATING+ etext = .};
45 /* rdata - Read Only Runtime Data
46 CTR sections: All of the CRT (read only C runtime data) sections
47 appear at the start of the .rdata (read only runtime data)
48 section, in the following order. Don't know if it matters or not.
49 Not all sections are always present either.
50 .rdata: compiler generated read only data
51 .xdata: compiler generated exception handling table. (Most docs
52 seem to suggest that this section is now deprecated infavor
54 .edata: The exported names table.
56 .rdata BLOCK(__section_alignment__) :
75 .edata BLOCK(__section_alignment__) :
80 /* data - initialized data
81 .ydata: exception handling information.
82 .data: the usual meaning.
83 .data2: more of the same.
84 .bss: For some reason, bss appears to be included in the data
85 section, as opposed to being given a section of it's own.
88 .data BLOCK(__section_alignment__) :
98 ${RELOCATING+ end = .};
102 /* The exception handling table. A sequence of 5 word entries. Section
103 address and extent are placed in the DataDirectory.
105 .pdata BLOCK(__section_alignment__) :
111 /* The idata section is chock full of magic bits.
112 1. Boundaries around various idata parts are used to initialize
113 some of the fields of the DataDirectory. In particular, the
114 magic for 2, 4 and 5 are known to be used. Some compilers
115 appear to generate magic section symbols for this purpose.
116 Where we can, we catch such symbols and use our own. This of
117 course is something less than a perfect strategy.
118 2. The table of contents is placed immediately after idata4.
119 The ".private.toc" sections are generated by the ppc bfd. The
120 .toc variable is generated by gas, and resolved here. It is
121 used to initialized function descriptors (and anyone else who
122 needs the address of the module's toc). The only thing
123 interesting about it at all? Most ppc instructions using it
124 have a 16bit displacement field. The convention for addressing
125 is to initialize the .toc value to 32K past the start of the
126 actual toc, and subtract 32K from all references, thus using
127 the entire 64K range. Naturally, the reloc code must agree
128 on this number or you get pretty stupid results.
130 .idata BLOCK(__section_alignment__) :
132 __idata2_magic__ = .;
134 __idata3_magic__ = .;
136 __idata4_magic__ = .;
141 __idata5_magic__ = .;
143 __idata6_magic__ = .;
145 __idata7_magic__ = .;
150 /* reldata -- data that requires relocation
152 .reldata BLOCK(__section_alignment__) :
160 .rsrc BLOCK(__section_alignment__) :
167 .stab BLOCK(__section_alignment__) ${RELOCATING+(NOLOAD)} :
172 .stabstr BLOCK(__section_alignment__) ${RELOCATING+(NOLOAD)} :
177 /* The .reloc section is currently generated by the dlltool from Steve
178 Chamberlain in a second pass of linking. Section address and extent
179 are placed in the DataDirectory.
181 .reloc BLOCK(__section_alignment__) :
187 /* We don't do anything useful with codeview debugger support or the
188 directive section (yet). Hopefully, we junk them correctly.
190 /DISCARD/ BLOCK(__section_alignment__) :