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 * The linker symbols _prefix_link_addr, load_addr, and
19 * _max_align may be specified explicitly. If not specified, they
22 * _prefix_link_addr = 0
26 * We guarantee alignment of virtual addresses to any alignment
27 * specified by the constituent object files (e.g. via
28 * __attribute__((aligned(x)))). Load addresses are guaranteed
29 * only up to _max_align. Provided that all loader and relocation
30 * code honours _max_align, this means that physical addresses are
31 * also guaranteed up to _max_align.
33 * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
34 * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
35 * alignment). Using _max_align>16 will therefore not guarantee
36 * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
37 * used (though virtual addresses will still be fully aligned).
45 _prefix_link_addr = DEFINED ( _prefix_link_addr ) ? _prefix_link_addr : 0;
46 . = _prefix_link_addr;
49 .prefix : AT ( _prefix_load_offset + __prefix ) {
54 _eprefix_progbits = .;
63 _text16_link_addr = 0;
64 . = _text16_link_addr;
67 . += 1; /* Prevent NULL being valid */
69 .text16 : AT ( _text16_load_offset + __text16 ) {
76 _etext16_progbits = .;
81 _data16_link_addr = 0;
82 . = _data16_link_addr;
85 . += 1; /* Prevent NULL being valid */
87 .rodata16 : AT ( _data16_load_offset + __rodata16 ) {
94 .data16 : AT ( _data16_load_offset + __data16 ) {
100 *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
101 _edata16_progbits = .;
103 .bss16 : AT ( _data16_load_offset + __bss16 ) {
113 .stack16 : AT ( _data16_load_offset + __stack16 ) {
126 * Dispose of the comment and note sections to make the link map
137 * Load address calculations. The slightly obscure nature of the
138 * calculations is because ALIGN(x) can only operate on the
142 _max_align = DEFINED ( _max_align ) ? _max_align : 16;
143 _load_addr = DEFINED ( _load_addr ) ? _load_addr : 0;
147 . -= _prefix_link_addr;
148 _prefix_load_offset = ALIGN ( _max_align );
149 _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
150 _prefix_size = _eprefix - _prefix;
151 _prefix_progbits_size = _eprefix_progbits - _prefix;
152 . = _prefix_load_addr + _prefix_progbits_size;
154 . -= _text16_link_addr;
155 _text16_load_offset = ALIGN ( _max_align );
156 _text16_load_addr = _text16_link_addr + _text16_load_offset;
157 _text16_size = _etext16 - _text16;
158 _text16_progbits_size = _etext16_progbits - _text16;
159 . = _text16_load_addr + _text16_progbits_size;
161 . -= _data16_link_addr;
162 _data16_load_offset = ALIGN ( _max_align );
163 _data16_load_addr = _data16_link_addr + _data16_load_offset;
164 _data16_size = _edata16 - _data16;
165 _data16_progbits_size = _edata16_progbits - _data16;
166 . = _data16_load_addr + _data16_progbits_size;
168 . = ALIGN ( _max_align );
170 _load_size = . - _load_addr;
173 * Alignment checks. ALIGN() can only operate on the location
174 * counter, so we set the location counter to each value we want
178 . = _prefix_load_addr - _prefix_link_addr;
179 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
180 "_prefix is badly aligned" );
182 . = _text16_load_addr - _text16_link_addr;
183 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
184 "_text16 is badly aligned" );
186 . = _data16_load_addr - _data16_link_addr;
187 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
188 "_data16 is badly aligned" );
191 * Values calculated to save code from doing it
193 _text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
194 _data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
195 _load_size_pgh = ( ( _load_size + 15 ) / 16 );
196 _load_size_sect = ( ( _load_size + 511 ) / 512 );