4 * Linker script for i386 images
8 OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
14 /* All sections in the resulting file have consecutive load
15 * addresses, but may have individual link addresses depending on
16 * the memory model being used.
18 * We guarantee alignment of virtual addresses to any alignment
19 * specified by the constituent object files (e.g. via
20 * __attribute__((aligned(x)))). Load addresses are guaranteed
21 * only up to _max_align. Provided that all loader and relocation
22 * code honours _max_align, this means that physical addresses are
23 * also guaranteed up to _max_align.
25 * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
26 * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
27 * alignment). Using _max_align>16 will therefore not guarantee
28 * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
29 * used (though virtual addresses will still be fully aligned).
37 _prefix_link_addr = 0;
38 . = _prefix_link_addr;
41 .prefix : AT ( _prefix_load_offset + __prefix ) {
46 _eprefix_progbits = .;
52 * The 16-bit sections, if present
55 _text16_link_addr = 0;
56 . = _text16_link_addr;
59 . += 1; /* Prevent NULL being valid */
61 .text16 : AT ( _text16_load_offset + __text16 ) {
65 _etext16_progbits = .;
70 _data16_link_addr = 0;
71 . = _data16_link_addr;
74 . += 1; /* Prevent NULL being valid */
76 .rodata16 : AT ( _data16_load_offset + __rodata16 ) {
81 .data16 : AT ( _data16_load_offset + __data16 ) {
85 _edata16_progbits = .;
87 .bss16 : AT ( _data16_load_offset + __bss16 ) {
94 .stack16 : AT ( _data16_load_offset + __stack16 ) {
103 * The 32-bit sections
106 _textdata_link_addr = 0;
107 . = _textdata_link_addr;
112 . += 1; /* Prevent NULL being valid */
114 .text : AT ( _textdata_load_offset + __text ) {
125 .rodata : AT ( _textdata_load_offset + __rodata ) {
130 .data : AT ( _textdata_load_offset + __data ) {
134 *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
135 _etextdata_progbits = .;
137 .bss : AT ( _textdata_load_offset + __bss ) {
145 .stack : AT ( _textdata_load_offset + __stack ) {
158 * Compressor information block
161 _zinfo_link_addr = 0;
162 . = _zinfo_link_addr;
165 .zinfo : AT ( _zinfo_load_offset + __zinfo ) {
170 _ezinfo_progbits = .;
176 * Dispose of the comment and note sections to make the link map
186 * Load address calculations. The slightly obscure nature of the
187 * calculations is because ALIGN(x) can only operate on the
196 . -= _prefix_link_addr;
197 _prefix_load_offset = ALIGN ( _max_align );
198 _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
199 _prefix_size = _eprefix - _prefix;
200 _prefix_progbits_size = _eprefix_progbits - _prefix;
201 . = _prefix_load_addr + _prefix_progbits_size;
203 . -= _text16_link_addr;
204 _text16_load_offset = ALIGN ( _max_align );
205 _text16_load_addr = _text16_link_addr + _text16_load_offset;
206 _text16_size = _etext16 - _text16;
207 _text16_progbits_size = _etext16_progbits - _text16;
208 . = _text16_load_addr + _text16_progbits_size;
210 . -= _data16_link_addr;
211 _data16_load_offset = ALIGN ( _max_align );
212 _data16_load_addr = _data16_link_addr + _data16_load_offset;
213 _data16_size = _edata16 - _data16;
214 _data16_progbits_size = _edata16_progbits - _data16;
215 . = _data16_load_addr + _data16_progbits_size;
217 . -= _textdata_link_addr;
218 _textdata_load_offset = ALIGN ( _max_align );
219 _textdata_load_addr = _textdata_link_addr + _textdata_load_offset;
220 _textdata_size = _etextdata - _textdata;
221 _textdata_progbits_size = _etextdata_progbits - _textdata;
222 . = _textdata_load_addr + _textdata_progbits_size;
224 _load_size = . - _load_addr;
226 . -= _zinfo_link_addr;
227 _zinfo_load_offset = ALIGN ( _max_align );
228 _zinfo_load_addr = _zinfo_link_addr + _zinfo_load_offset;
229 _zinfo_size = _ezinfo - _zinfo;
230 _zinfo_progbits_size = _ezinfo_progbits - _zinfo;
231 . = _zinfo_load_addr + _zinfo_progbits_size;
233 _payload_offset = _text16_load_offset;
236 * Alignment checks. ALIGN() can only operate on the location
237 * counter, so we set the location counter to each value we want
241 . = _prefix_load_addr - _prefix_link_addr;
242 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
243 "_prefix is badly aligned" );
245 . = _text16_load_addr - _text16_link_addr;
246 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
247 "_text16 is badly aligned" );
249 . = _data16_load_addr - _data16_link_addr;
250 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
251 "_data16 is badly aligned" );
253 . = _textdata_load_addr - _textdata_link_addr;
254 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
255 "_text is badly aligned" );
258 * Values calculated to save code from doing it
260 _text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
261 _data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
264 * Load sizes in paragraphs and sectors. Note that wherever the
265 * _load_size variables are used, there must be a corresponding
266 * .zinfo.fixup section.
268 _load_size_pgh = ( ( _load_size + 15 ) / 16 );
269 _load_size_sect = ( ( _load_size + 511 ) / 512 );