1
/* -*- ld-script -*- */
4
* Linker script for i386 images
10
/* Each section starts at a virtual address of zero.
12
* We guarantee alignment of virtual addresses to any alignment
13
* specified by the constituent object files (e.g. via
14
* __attribute__((aligned(x)))). Load addresses are guaranteed
15
* only up to _max_align. Provided that all loader and relocation
16
* code honours _max_align, this means that physical addresses are
17
* also guaranteed up to _max_align.
19
* Note that when using -DKEEP_IT_REAL, the UNDI segments are only
20
* guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
21
* alignment). Using _max_align>16 will therefore not guarantee
22
* >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
23
* used (though virtual addresses will still be fully aligned).
27
PROVIDE ( _max_align = 16 );
30
* Values used in page table calculations
32
* On older versions of ld (without the SANE_EXPR feature),
33
* numeric literals within a section description tend to be
34
* interpreted as section-relative symbols.
38
_page_size_1 = ( _page_size - 1 );
40
_pte_count = ( _page_size / _pte_size );
41
_pte_count_1 = ( _pte_count - 1 );
44
* Allow decompressor to require a minimum amount of temporary stack
48
PROVIDE ( _min_decompress_stack = 0 );
55
.prefix 0x0 : AT ( _prefix_lma ) {
58
*(SORT(.pci_devlist.*))
61
} .bss.prefix (NOLOAD) : AT ( _end_lma ) {
64
_prefix_filesz = ABSOLUTE ( _mprefix ) - ABSOLUTE ( _prefix );
65
_prefix_memsz = ABSOLUTE ( _eprefix ) - ABSOLUTE ( _prefix );
68
* The 16-bit (real-mode) code section
72
.text16.early 0x0 : AT ( _text16_early_lma ) {
75
KEEP(*(.text16.null.*))
76
. += 1; /* Prevent NULL being valid */
80
} .text16.late ALIGN ( _max_align ) : AT ( _text16_late_lma ) {
85
} .bss.text16 (NOLOAD) : AT ( _end_lma ) {
88
_text16_early_filesz = ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 );
89
_text16_early_memsz = ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 );
90
_text16_late_filesz = ABSOLUTE ( _mtext16 ) - ABSOLUTE ( _text16_late );
91
_text16_late_memsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16_late );
92
_text16_memsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16 );
95
* The 16-bit (real-mode) data section
99
.data16 0x0 : AT ( _data16_lma ) {
101
. += 1; /* Prevent NULL being valid */
107
} .bss.data16 (NOLOAD) : AT ( _end_lma ) {
112
. = MAX ( ., _mdata16 + _min_decompress_stack );
115
_data16_filesz = ABSOLUTE ( _mdata16 ) - ABSOLUTE ( _data16 );
116
_data16_memsz = ABSOLUTE ( _edata16 ) - ABSOLUTE ( _data16 );
119
* The 32-bit sections
123
.textdata 0x0 : AT ( _textdata_lma ) {
125
KEEP(*(.text.null_trap))
126
KEEP(*(.text.null_trap.*))
127
. += 1; /* Prevent NULL being valid */
134
KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */
138
} .bss.textdata (NOLOAD) : AT ( _end_lma ) {
147
_use_page_tables = ABSOLUTE ( . ) - ABSOLUTE ( _pages );
148
_textdata_paged_len =
149
ABSOLUTE ( ABSOLUTE ( . ) - ABSOLUTE ( _textdata ) );
151
ABSOLUTE ( ( _textdata_paged_len + _page_size_1 ) / _page_size );
153
ABSOLUTE ( ( _textdata_ptes + _pte_count_1 ) / _pte_count );
154
. += ( _use_page_tables ? ( _textdata_pdes * _page_size ) : 0 );
158
_textdata_filesz = ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata );
159
_textdata_memsz = ABSOLUTE ( _etextdata ) - ABSOLUTE ( _textdata );
164
* If present, this will be placed between .text16.early and .text16.late.
167
.pprefix 0x0 : AT ( _pprefix_lma ) {
172
} .bss.pprefix (NOLOAD) : AT ( _end_lma ) {
175
_pprefix_filesz = ABSOLUTE ( _mpprefix ) - ABSOLUTE ( _pprefix );
176
_pprefix_memsz = ABSOLUTE ( _epprefix ) - ABSOLUTE ( _pprefix );
179
* Compressor information block
183
.zinfo 0x0 : AT ( _zinfo_lma ) {
188
} .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
191
_zinfo_filesz = ABSOLUTE ( _mzinfo ) - ABSOLUTE ( _zinfo );
192
_zinfo_memsz = ABSOLUTE ( _ezinfo ) - ABSOLUTE ( _zinfo );
195
* Weak symbols that need zero values if not otherwise defined
199
.weak 0x0 : AT ( _end_lma ) {
205
_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
208
* Dispose of the comment and note sections to make the link map
229
* Load address calculations. In older versions of ld, ALIGN()
230
* can operate only on the location counter, so we use that.
236
. = ALIGN ( _max_align );
240
. = ALIGN ( _max_align );
241
_text16_early_lma = .;
242
. += _text16_early_filesz;
244
. = ALIGN ( _max_align );
245
. = ALIGN ( _payload_align );
247
. += _pprefix_filesz;
249
. = ALIGN ( _max_align );
251
_pprefix_skip = ABSOLUTE ( _payload_lma ) - ABSOLUTE ( _pprefix_lma );
252
_text16_late_lma = .;
253
. += _text16_late_filesz;
255
. = ALIGN ( _max_align );
259
. = ALIGN ( _max_align );
261
. += _textdata_filesz;
263
_filesz = .; /* Do not include zinfo block in file size */
265
. = ALIGN ( _max_align );
269
. = ALIGN ( _max_align );
273
* Values calculated to save code from doing it
276
_text16_memsz_ppgh = ( ( ( _text16_memsz + 63 ) / 64 ) * 4 );
277
_data16_memsz_ppgh = ( ( ( _data16_memsz + 63 ) / 64 ) * 4 );
278
_textdata_memsz_pgh = ( ( _textdata_memsz + 15 ) / 16 );
279
_textdata_memsz_kb = ( ( _textdata_memsz + 1023 ) / 1024 );