summaryrefslogtreecommitdiff
path: root/gpxe/src/arch/i386/scripts/i386.lds
blob: 33c75f9070eecc5b2e5ab814a64104946ed39fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/* -*- sh -*- */

/*
 * Linker script for i386 images
 *
 */

SECTIONS {

    /* Each section starts at a virtual address of zero.
     *
     * We guarantee alignment of virtual addresses to any alignment
     * specified by the constituent object files (e.g. via
     * __attribute__((aligned(x)))).  Load addresses are guaranteed
     * only up to _max_align.  Provided that all loader and relocation
     * code honours _max_align, this means that physical addresses are
     * also guaranteed up to _max_align.
     *
     * Note that when using -DKEEP_IT_REAL, the UNDI segments are only
     * guaranteed to be loaded on a paragraph boundary (i.e. 16-byte
     * alignment).  Using _max_align>16 will therefore not guarantee
     * >16-byte alignment of physical addresses when -DKEEP_IT_REAL is
     * used (though virtual addresses will still be fully aligned).
     *
     */

    /*
     * The prefix
     *
     */

    .prefix 0x0 : AT ( _prefix_lma ) {
	_prefix = .;
	*(.prefix)
	*(.prefix.*)
	_mprefix = .;
    } .bss.prefix (NOLOAD) : AT ( _end_lma ) {
	_eprefix = .;
    }
    _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
    _prefix_memsz	= ABSOLUTE ( _eprefix - _prefix );

    /*
     * The 16-bit (real-mode) code section
     *
     */

    .text16 0x0 : AT ( _text16_lma ) {
	_text16 = .;
	*(.text16.null)
	. += 1;				/* Prevent NULL being valid */
	*(.text16)
	*(.text16.*)
	_mtext16 = .;
    } .bss.text16 (NOLOAD) : AT ( _end_lma ) {
	_etext16 = .;
    }
    _text16_filesz	= ABSOLUTE ( _mtext16 - _text16 );
    _text16_memsz	= ABSOLUTE ( _etext16 - _text16 );

    /*
     * The 16-bit (real-mode) data section
     *
     */

    .data16 0x0 : AT ( _data16_lma ) {
	_data16 = .;
	. += 1;				/* Prevent NULL being valid */
	*(.rodata16)
	*(.rodata16.*)
	*(.data16)
	*(.data16.*)
	_mdata16 = .;
    } .bss.data16 (NOLOAD) : AT ( _end_lma ) {
	*(.bss16)
	*(.bss16.*)
	*(.stack16)
	*(.stack16.*)
	_edata16 = .;
    }
    _data16_filesz	= ABSOLUTE ( _mdata16 - _data16 );
    _data16_memsz	= ABSOLUTE ( _edata16 - _data16 );

    /*
     * The 32-bit sections
     *
     */

    .textdata 0x0 : AT ( _textdata_lma ) {
	_textdata = .;
	*(.text.null_trap)
	. += 1;				/* Prevent NULL being valid */
	*(.text)
	*(.text.*)
	*(.rodata)
	*(.rodata.*)
	*(.data)
	*(.data.*)
	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
	_mtextdata = .;
    } .bss.textdata (NOLOAD) : AT ( _end_lma ) {
	*(.bss)
	*(.bss.*)
	*(COMMON)
	*(.stack)
	*(.stack.*)
	_etextdata = .;
    }
    _textdata_filesz	= ABSOLUTE ( _mtextdata - _textdata );
    _textdata_memsz	= ABSOLUTE ( _etextdata - _textdata );

    /*
     * Compressor information block
     *
     */

    .zinfo 0x0 : AT ( _zinfo_lma ) {
	_zinfo = .;
	*(.zinfo)
	*(.zinfo.*)
	_mzinfo = .;
    } .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
	_ezinfo = .;
    }
    _zinfo_filesz	= ABSOLUTE ( _mzinfo - _zinfo );
    _zinfo_memsz	= ABSOLUTE ( _ezinfo - _zinfo );

    /*
     * Weak symbols that need zero values if not otherwise defined
     *
     */

    .weak 0x0 : AT ( _end_lma ) {
	_weak = .;
	*(.weak)
	_eweak = .;
    }
    _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );

    /*
     * Dispose of the comment and note sections to make the link map
     * easier to read
     *
     */

    /DISCARD/ : {
	*(.comment)
	*(.comment.*)
	*(.note)
	*(.note.*)
	*(.eh_frame)
	*(.eh_frame.*)
	*(.rel)
	*(.rel.*)
	*(.discard)
    }

    /*
     * Load address calculations.  In older versions of ld, ALIGN()
     * can operate only on the location counter, so we use that.
     *
     */

    PROVIDE ( _max_align = 16 );
    .			= 0;

    .			= ALIGN ( _max_align );
    _prefix_lma		= .;
    .			+= _prefix_filesz;

    .			= ALIGN ( _max_align );
    _payload_lma	= .;
    _text16_lma		= .;
    .			+= _text16_filesz;

    .			= ALIGN ( _max_align );
    _data16_lma		= .;
    .			+= _data16_filesz;

    .			= ALIGN ( _max_align );
    _textdata_lma	= .;
    .			+= _textdata_filesz;

    _filesz		= .; /* Do not include zinfo block in file size */

    .			= ALIGN ( _max_align );
    _zinfo_lma		= .;
    .			+= _zinfo_filesz;

    .			= ALIGN ( _max_align );
    _end_lma		= .;

    /*
     * Values calculated to save code from doing it
     *
     */
    _prefix_filesz_sect = ( ( _prefix_filesz + 511 ) / 512 );
    _prefix_memsz_pgh	= ( ( _prefix_memsz + 15 ) / 16 );
    _prefix_memsz_sect	= ( ( _prefix_memsz + 511 ) / 512 );
    _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
    _data16_memsz_pgh	= ( ( _data16_memsz + 15 ) / 16 );
}