|
@@ -5,15 +5,9 @@
|
5
|
5
|
*
|
6
|
6
|
*/
|
7
|
7
|
|
8
|
|
-OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
|
9
|
|
-OUTPUT_ARCH ( i386 )
|
10
|
|
-ENTRY ( _entry )
|
11
|
|
-
|
12
|
8
|
SECTIONS {
|
13
|
9
|
|
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.
|
|
10
|
+ /* Each section starts at a virtual address of zero.
|
17
|
11
|
*
|
18
|
12
|
* We guarantee alignment of virtual addresses to any alignment
|
19
|
13
|
* specified by the constituent object files (e.g. via
|
|
@@ -30,163 +24,123 @@ SECTIONS {
|
30
|
24
|
*
|
31
|
25
|
*/
|
32
|
26
|
|
33
|
|
- /*
|
34
|
|
- * Weak symbols that need zero values if not otherwise defined
|
35
|
|
- */
|
36
|
|
-
|
37
|
|
- . = 0;
|
38
|
|
- .weak : AT ( 0 ) {
|
39
|
|
- *(.weak)
|
40
|
|
- }
|
41
|
|
- _assert = ASSERT ( ( . == 0 ), ".weak is non-zero length" );
|
42
|
|
-
|
43
|
27
|
/*
|
44
|
28
|
* The prefix
|
|
29
|
+ *
|
45
|
30
|
*/
|
46
|
31
|
|
47
|
|
- _prefix_link_addr = 0;
|
48
|
|
- . = _prefix_link_addr;
|
49
|
|
- _prefix = .;
|
50
|
|
-
|
51
|
|
- .prefix : AT ( _prefix_load_offset + __prefix ) {
|
52
|
|
- __prefix = .;
|
53
|
|
- _entry = .;
|
|
32
|
+ .prefix 0x0 : AT ( _prefix_lma ) {
|
|
33
|
+ _prefix = .;
|
54
|
34
|
*(.prefix)
|
55
|
35
|
*(.prefix.*)
|
56
|
|
- _eprefix_progbits = .;
|
|
36
|
+ _mprefix = .;
|
|
37
|
+ } .prefix_bss (NOLOAD) : {
|
|
38
|
+ _eprefix = .;
|
57
|
39
|
}
|
58
|
|
-
|
59
|
|
- _eprefix = .;
|
|
40
|
+ _prefix_filesz = ABSOLUTE ( _mprefix - _prefix );
|
|
41
|
+ _prefix_memsz = ABSOLUTE ( _eprefix - _prefix );
|
60
|
42
|
|
61
|
43
|
/*
|
62
|
|
- * The 16-bit sections, if present
|
|
44
|
+ * The 16-bit (real-mode) code section
|
|
45
|
+ *
|
63
|
46
|
*/
|
64
|
47
|
|
65
|
|
- _text16_link_addr = 0;
|
66
|
|
- . = _text16_link_addr;
|
67
|
|
- _text16 = .;
|
68
|
|
-
|
69
|
|
- /* We need to allow code at the NULL address in .text16 */
|
70
|
|
-
|
71
|
|
- .text16 : AT ( _text16_load_offset + __text16 ) {
|
72
|
|
- __text16 = .;
|
|
48
|
+ .text16 0x0 : AT ( _text16_lma ) {
|
|
49
|
+ _text16 = .;
|
73
|
50
|
*(.text16.null)
|
74
|
|
- . += 1; /* Prevent NULL being valid */
|
|
51
|
+ . += 1; /* Prevent NULL being valid */
|
75
|
52
|
*(.text16)
|
76
|
53
|
*(.text16.*)
|
77
|
|
- _etext16_progbits = .;
|
78
|
|
- } = 0x9090
|
79
|
|
-
|
80
|
|
- _etext16 = .;
|
81
|
|
-
|
82
|
|
- _data16_link_addr = 0;
|
83
|
|
- . = _data16_link_addr;
|
84
|
|
- _data16 = .;
|
|
54
|
+ _mtext16 = .;
|
|
55
|
+ } .text16_bss (NOLOAD) : {
|
|
56
|
+ _etext16 = .;
|
|
57
|
+ }
|
|
58
|
+ _text16_filesz = ABSOLUTE ( _mtext16 - _text16 );
|
|
59
|
+ _text16_memsz = ABSOLUTE ( _etext16 - _text16 );
|
85
|
60
|
|
86
|
|
- . += 1; /* Prevent NULL being valid */
|
|
61
|
+ /*
|
|
62
|
+ * The 16-bit (real-mode) data section
|
|
63
|
+ *
|
|
64
|
+ */
|
87
|
65
|
|
88
|
|
- .rodata16 : AT ( _data16_load_offset + __rodata16 ) {
|
89
|
|
- __rodata16 = .;
|
|
66
|
+ .data16 0x0 : AT ( _data16_lma ) {
|
|
67
|
+ _data16 = .;
|
|
68
|
+ . += 1; /* Prevent NULL being valid */
|
90
|
69
|
*(.rodata16)
|
91
|
70
|
*(.rodata16.*)
|
92
|
|
- }
|
93
|
|
- .data16 : AT ( _data16_load_offset + __data16 ) {
|
94
|
|
- __data16 = .;
|
95
|
71
|
*(.data16)
|
96
|
72
|
*(.data16.*)
|
97
|
|
- _edata16_progbits = .;
|
98
|
|
- }
|
99
|
|
- .bss16 : AT ( _data16_load_offset + __bss16 ) {
|
100
|
|
- __bss16 = .;
|
101
|
|
- _bss16 = .;
|
|
73
|
+ _mdata16 = .;
|
|
74
|
+ } .data16_bss (NOLOAD) : {
|
102
|
75
|
*(.bss16)
|
103
|
76
|
*(.bss16.*)
|
104
|
|
- _ebss16 = .;
|
105
|
|
- }
|
106
|
|
- .stack16 : AT ( _data16_load_offset + __stack16 ) {
|
107
|
|
- __stack16 = .;
|
108
|
77
|
*(.stack16)
|
109
|
78
|
*(.stack16.*)
|
|
79
|
+ _edata16 = .;
|
110
|
80
|
}
|
111
|
|
-
|
112
|
|
- _edata16 = .;
|
|
81
|
+ _data16_filesz = ABSOLUTE ( _mdata16 - _data16 );
|
|
82
|
+ _data16_memsz = ABSOLUTE ( _edata16 - _data16 );
|
113
|
83
|
|
114
|
84
|
/*
|
115
|
85
|
* The 32-bit sections
|
|
86
|
+ *
|
116
|
87
|
*/
|
117
|
88
|
|
118
|
|
- _textdata_link_addr = 0;
|
119
|
|
- . = _textdata_link_addr;
|
120
|
|
- _textdata = .;
|
121
|
|
-
|
122
|
|
- _text = .;
|
123
|
|
-
|
124
|
|
- . += 1; /* Prevent NULL being valid */
|
125
|
|
-
|
126
|
|
- .text : AT ( _textdata_load_offset + __text ) {
|
127
|
|
- __text = .;
|
|
89
|
+ .textdata 0x0 : AT ( _textdata_lma ) {
|
|
90
|
+ _textdata = .;
|
128
|
91
|
*(.text.null_trap)
|
|
92
|
+ . += 1; /* Prevent NULL being valid */
|
129
|
93
|
*(.text)
|
130
|
94
|
*(.text.*)
|
131
|
|
- } = 0x9090
|
132
|
|
-
|
133
|
|
- _etext = .;
|
134
|
|
-
|
135
|
|
- _data = .;
|
136
|
|
-
|
137
|
|
- .rodata : AT ( _textdata_load_offset + __rodata ) {
|
138
|
|
- __rodata = .;
|
139
|
95
|
*(.rodata)
|
140
|
96
|
*(.rodata.*)
|
141
|
|
- }
|
142
|
|
- .data : AT ( _textdata_load_offset + __data ) {
|
143
|
|
- __data = .;
|
144
|
97
|
*(.data)
|
145
|
98
|
*(.data.*)
|
146
|
99
|
*(SORT(.tbl.*)) /* Various tables. See include/tables.h */
|
147
|
|
- _etextdata_progbits = .;
|
148
|
|
- }
|
149
|
|
- .bss : AT ( _textdata_load_offset + __bss ) {
|
150
|
|
- __bss = .;
|
151
|
|
- _bss = .;
|
|
100
|
+ _mtextdata = .;
|
|
101
|
+ } .textdata_bss (NOLOAD) : {
|
152
|
102
|
*(.bss)
|
153
|
103
|
*(.bss.*)
|
154
|
104
|
*(COMMON)
|
155
|
|
- _ebss = .;
|
156
|
|
- }
|
157
|
|
- .stack : AT ( _textdata_load_offset + __stack ) {
|
158
|
|
- __stack = .;
|
159
|
105
|
*(.stack)
|
160
|
106
|
*(.stack.*)
|
|
107
|
+ _etextdata = .;
|
161
|
108
|
}
|
162
|
|
-
|
163
|
|
- _edata = .;
|
164
|
|
-
|
165
|
|
- _etextdata = .;
|
166
|
|
-
|
167
|
|
- _end = .;
|
|
109
|
+ _textdata_filesz = ABSOLUTE ( _mtextdata - _textdata );
|
|
110
|
+ _textdata_memsz = ABSOLUTE ( _etextdata - _textdata );
|
168
|
111
|
|
169
|
112
|
/*
|
170
|
113
|
* Compressor information block
|
|
114
|
+ *
|
171
|
115
|
*/
|
172
|
116
|
|
173
|
|
- _zinfo_link_addr = 0;
|
174
|
|
- . = _zinfo_link_addr;
|
175
|
|
- _zinfo = .;
|
176
|
|
-
|
177
|
|
- .zinfo : AT ( _zinfo_load_offset + __zinfo ) {
|
178
|
|
- __zinfo = .;
|
179
|
|
- _entry = .;
|
|
117
|
+ .zinfo 0x0 : AT ( _zinfo_lma ) {
|
|
118
|
+ _zinfo = .;
|
180
|
119
|
*(.zinfo)
|
181
|
120
|
*(.zinfo.*)
|
182
|
|
- _ezinfo_progbits = .;
|
|
121
|
+ _mzinfo = .;
|
|
122
|
+ } .zinfo_bss (NOLOAD) : {
|
|
123
|
+ _ezinfo = .;
|
183
|
124
|
}
|
184
|
|
-
|
185
|
|
- _ezinfo = .;
|
|
125
|
+ _zinfo_filesz = ABSOLUTE ( _mzinfo - _zinfo );
|
|
126
|
+ _zinfo_memsz = ABSOLUTE ( _ezinfo - _zinfo );
|
|
127
|
+
|
|
128
|
+ /*
|
|
129
|
+ * Weak symbols that need zero values if not otherwise defined
|
|
130
|
+ *
|
|
131
|
+ */
|
|
132
|
+
|
|
133
|
+ .weak 0x0 : {
|
|
134
|
+ _weak = .;
|
|
135
|
+ *(.weak)
|
|
136
|
+ _eweak = .;
|
|
137
|
+ }
|
|
138
|
+ _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
|
186
|
139
|
|
187
|
140
|
/*
|
188
|
141
|
* Dispose of the comment and note sections to make the link map
|
189
|
142
|
* easier to read
|
|
143
|
+ *
|
190
|
144
|
*/
|
191
|
145
|
|
192
|
146
|
/DISCARD/ : {
|
|
@@ -195,90 +149,53 @@ SECTIONS {
|
195
|
149
|
}
|
196
|
150
|
|
197
|
151
|
/*
|
198
|
|
- * Load address calculations. The slightly obscure nature of the
|
199
|
|
- * calculations is because ALIGN(x) can only operate on the
|
200
|
|
- * location counter.
|
|
152
|
+ * Load address calculations. In older versions of ld, ALIGN()
|
|
153
|
+ * can operate only on the location counter, so we use that.
|
|
154
|
+ *
|
201
|
155
|
*/
|
202
|
156
|
|
203
|
|
- _max_align = 16;
|
204
|
|
- _load_addr = 0;
|
205
|
|
-
|
206
|
|
- . = _load_addr;
|
207
|
|
-
|
208
|
|
- . -= _prefix_link_addr;
|
209
|
|
- _prefix_load_offset = ALIGN ( _max_align );
|
210
|
|
- _prefix_load_addr = _prefix_link_addr + _prefix_load_offset;
|
211
|
|
- _prefix_size = _eprefix - _prefix;
|
212
|
|
- _prefix_progbits_size = _eprefix_progbits - _prefix;
|
213
|
|
- . = _prefix_load_addr + _prefix_progbits_size;
|
214
|
|
-
|
215
|
|
- . -= _text16_link_addr;
|
216
|
|
- _text16_load_offset = ALIGN ( _max_align );
|
217
|
|
- _text16_load_addr = _text16_link_addr + _text16_load_offset;
|
218
|
|
- _text16_size = _etext16 - _text16;
|
219
|
|
- _text16_progbits_size = _etext16_progbits - _text16;
|
220
|
|
- . = _text16_load_addr + _text16_progbits_size;
|
|
157
|
+ PROVIDE ( _max_align = 16 );
|
|
158
|
+ . = 0;
|
221
|
159
|
|
222
|
|
- . -= _data16_link_addr;
|
223
|
|
- _data16_load_offset = ALIGN ( _max_align );
|
224
|
|
- _data16_load_addr = _data16_link_addr + _data16_load_offset;
|
225
|
|
- _data16_size = _edata16 - _data16;
|
226
|
|
- _data16_progbits_size = _edata16_progbits - _data16;
|
227
|
|
- . = _data16_load_addr + _data16_progbits_size;
|
|
160
|
+ _prefix_lma = .;
|
|
161
|
+ . += _prefix_filesz;
|
|
162
|
+ . = ALIGN ( _max_align );
|
228
|
163
|
|
229
|
|
- . -= _textdata_link_addr;
|
230
|
|
- _textdata_load_offset = ALIGN ( _max_align );
|
231
|
|
- _textdata_load_addr = _textdata_link_addr + _textdata_load_offset;
|
232
|
|
- _textdata_size = _etextdata - _textdata;
|
233
|
|
- _textdata_progbits_size = _etextdata_progbits - _textdata;
|
234
|
|
- . = _textdata_load_addr + _textdata_progbits_size;
|
|
164
|
+ _payload_lma = .;
|
235
|
165
|
|
236
|
|
- _load_size = . - _load_addr;
|
|
166
|
+ _text16_lma = .;
|
|
167
|
+ . += _text16_filesz;
|
|
168
|
+ . = ALIGN ( _max_align );
|
237
|
169
|
|
238
|
|
- . -= _zinfo_link_addr;
|
239
|
|
- _zinfo_load_offset = ALIGN ( _max_align );
|
240
|
|
- _zinfo_load_addr = _zinfo_link_addr + _zinfo_load_offset;
|
241
|
|
- _zinfo_size = _ezinfo - _zinfo;
|
242
|
|
- _zinfo_progbits_size = _ezinfo_progbits - _zinfo;
|
243
|
|
- . = _zinfo_load_addr + _zinfo_progbits_size;
|
|
170
|
+ _data16_lma = .;
|
|
171
|
+ . += _data16_filesz;
|
|
172
|
+ . = ALIGN ( _max_align );
|
244
|
173
|
|
245
|
|
- _payload_offset = _text16_load_offset;
|
|
174
|
+ _textdata_lma = .;
|
|
175
|
+ . += _textdata_filesz;
|
|
176
|
+ . = ALIGN ( _max_align );
|
246
|
177
|
|
247
|
|
- /*
|
248
|
|
- * Alignment checks. ALIGN() can only operate on the location
|
249
|
|
- * counter, so we set the location counter to each value we want
|
250
|
|
- * to check.
|
251
|
|
- */
|
252
|
|
-
|
253
|
|
- . = _prefix_load_addr - _prefix_link_addr;
|
254
|
|
- _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
255
|
|
- "_prefix is badly aligned" );
|
256
|
|
-
|
257
|
|
- . = _text16_load_addr - _text16_link_addr;
|
258
|
|
- _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
259
|
|
- "_text16 is badly aligned" );
|
|
178
|
+ _filesz = .; /* Do not include zinfo block in file size */
|
260
|
179
|
|
261
|
|
- . = _data16_load_addr - _data16_link_addr;
|
262
|
|
- _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
263
|
|
- "_data16 is badly aligned" );
|
264
|
|
-
|
265
|
|
- . = _textdata_load_addr - _textdata_link_addr;
|
266
|
|
- _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
|
267
|
|
- "_text is badly aligned" );
|
|
180
|
+ _zinfo_lma = .;
|
|
181
|
+ . += _zinfo_filesz;
|
|
182
|
+ . = ALIGN ( _max_align );
|
268
|
183
|
|
269
|
184
|
/*
|
270
|
185
|
* Values calculated to save code from doing it
|
|
186
|
+ *
|
271
|
187
|
*/
|
272
|
|
- _prefix_size_pgh = ( ( _prefix_size + 15 ) / 16 );
|
273
|
|
- _prefix_size_sect = ( ( _prefix_size + 511 ) / 512 );
|
274
|
|
- _text16_size_pgh = ( ( _text16_size + 15 ) / 16 );
|
275
|
|
- _data16_size_pgh = ( ( _data16_size + 15 ) / 16 );
|
|
188
|
+ _prefix_memsz_pgh = ( ( _prefix_memsz + 15 ) / 16 );
|
|
189
|
+ _prefix_memsz_sect = ( ( _prefix_memsz + 511 ) / 512 );
|
|
190
|
+ _text16_memsz_pgh = ( ( _text16_memsz + 15 ) / 16 );
|
|
191
|
+ _data16_memsz_pgh = ( ( _data16_memsz + 15 ) / 16 );
|
276
|
192
|
|
277
|
193
|
/*
|
278
|
|
- * Load sizes in paragraphs and sectors. Note that wherever the
|
279
|
|
- * _load_size variables are used, there must be a corresponding
|
|
194
|
+ * File size in paragraphs and sectors. Note that wherever the
|
|
195
|
+ * _filesz variables are used, there must be a corresponding
|
280
|
196
|
* .zinfo.fixup section.
|
|
197
|
+ *
|
281
|
198
|
*/
|
282
|
|
- _load_size_pgh = ( ( _load_size + 15 ) / 16 );
|
283
|
|
- _load_size_sect = ( ( _load_size + 511 ) / 512 );
|
|
199
|
+ _filesz_pgh = ( ( _filesz + 15 ) / 16 );
|
|
200
|
+ _filesz_sect = ( ( _filesz + 511 ) / 512 );
|
284
|
201
|
}
|