4 * Linker script for i386 images
8 OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
13 /* All sections in the resulting file have consecutive load
14 * addresses, but may have individual link addresses depending on
15 * the memory model being used.
17 * The linker symbols _prefix_link_addr, load_addr, and
18 * _max_align may be specified explicitly. If not specified, they
21 * _prefix_link_addr = 0
25 * We guarantee alignment of virtual addresses to any alignment
26 * specified by the constituent object files (e.g. via
27 * __attribute__((aligned(x)))). Load addresses are guaranteed
28 * only up to _max_align. Provided that all loader and relocation
29 * code honours _max_align, this means that physical addresses are
30 * also guaranteed up to _max_align.
32 * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
33 * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
34 * alignment). Using _max_align>16 will therefore not guarantee
35 * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
36 * used (though virtual addresses will still be fully aligned).
44 _prefix_link_addr = DEFINED ( _prefix_link_addr ) ? _prefix_link_addr : 0;
45 . = _prefix_link_addr;
48 .prefix : AT ( _prefix_load_offset + __prefix ) {
53 _eprefix_progbits = .;
62 _text16_link_addr = 0;
63 . = _text16_link_addr;
66 . += 1; /* Prevent NULL being valid */
68 .text16 : AT ( _text16_load_offset + __text16 ) {
70 KEEP(*(.text.null_trap))
71 KEEP(*(.text.null_trap.*))
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 KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */
103 _edata16_progbits = .;
105 .bss16 : AT ( _data16_load_offset + __bss16 ) {
115 .stack16 : AT ( _data16_load_offset + __stack16 ) {
128 * Dispose of the comment and note sections to make the link map
142 * Load address calculations. The slightly obscure nature of the
143 * calculations is because ALIGN(x) can only operate on the
147 _max_align = DEFINED ( _max_align ) ? _max_align : 16;
148 _load_addr = DEFINED ( _load_addr ) ? _load_addr : 0;
152 . -= _prefix_link_addr;
153 _prefix_load_offset = ALIGN ( _max_align );
154 _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
155 _prefix_size = _eprefix - _prefix;
156 _prefix_progbits_size = _eprefix_progbits - _prefix;
157 . = _prefix_load_addr + _prefix_progbits_size;
159 . -= _text16_link_addr;
160 _text16_load_offset = ALIGN ( _max_align );
161 _text16_load_addr = _text16_link_addr + _text16_load_offset;
162 _text16_size = _etext16 - _text16;
163 _text16_progbits_size = _etext16_progbits - _text16;
164 . = _text16_load_addr + _text16_progbits_size;
166 . -= _data16_link_addr;
167 _data16_load_offset = ALIGN ( _max_align );
168 _data16_load_addr = _data16_link_addr + _data16_load_offset;
169 _data16_size = _edata16 - _data16;
170 _data16_progbits_size = _edata16_progbits - _data16;
171 . = _data16_load_addr + _data16_progbits_size;
173 . = ALIGN ( _max_align );
175 _load_size = . - _load_addr;
178 * Alignment checks. ALIGN() can only operate on the location
179 * counter, so we set the location counter to each value we want
183 . = _prefix_load_addr - _prefix_link_addr;
184 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
185 "_prefix is badly aligned" );
187 . = _text16_load_addr - _text16_link_addr;
188 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
189 "_text16 is badly aligned" );
191 . = _data16_load_addr - _data16_link_addr;
192 _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
193 "_data16 is badly aligned" );
196 * Values calculated to save code from doing it
198 _text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
199 _data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
200 _load_size_pgh = ( ( _load_size + 15 ) / 16 );
201 _load_size_sect = ( ( _load_size + 511 ) / 512 );