Browse Source

[build] Fix building on mildly deranged versions of binutils

Some versions of binutils have curious concepts of what constitutes
subtraction.  For example:

  0x00000000000000f0 _text16_late = .
  0x0000000000000898 _mtext16 = .
  0x0000000000000898 _etext16 = .
  0x0000000000000898 _text16_late_filesz = ABSOLUTE ((_mtext16 - _text16_late))
  0x00000000000007a8 _text16_late_memsz = ABSOLUTE ((_etext16 - _text16_late))

This has interesting side-effects such as producing sizes for .bss
segments that are negative, causing the majority of addressable memory
to be zeroed out.

Fix by using the form

  ABSOLUTE ( x ) - ABSOLUTE ( y )

rather than

  ABSOLUTE ( x - y )

Reported-by: H. Peter Anvin <hpa@zytor.com>
Suggested-by: H. Peter Anvin <hpa@zytor.com>
Tested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
987b825b7f
1 changed files with 13 additions and 13 deletions
  1. 13
    13
      src/arch/i386/scripts/i386.lds

+ 13
- 13
src/arch/i386/scripts/i386.lds View File

@@ -39,8 +39,8 @@ SECTIONS {
39 39
     } .bss.prefix (NOLOAD) : AT ( _end_lma ) {
40 40
 	_eprefix = .;
41 41
     }
42
-    _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
43
-    _prefix_memsz	= ABSOLUTE ( _eprefix - _prefix );
42
+    _prefix_filesz	= ABSOLUTE ( _mprefix ) - ABSOLUTE ( _prefix );
43
+    _prefix_memsz	= ABSOLUTE ( _eprefix ) - ABSOLUTE ( _prefix );
44 44
 
45 45
     /*
46 46
      * The 16-bit (real-mode) code section
@@ -63,11 +63,11 @@ SECTIONS {
63 63
     } .bss.text16 (NOLOAD) : AT ( _end_lma ) {
64 64
 	_etext16 = .;
65 65
     }
66
-    _text16_early_filesz = ABSOLUTE ( _etext16_early - _text16 );
67
-    _text16_early_memsz	= ABSOLUTE ( _etext16_early - _text16 );
68
-    _text16_late_filesz	= ABSOLUTE ( _mtext16 - _text16_late );
69
-    _text16_late_memsz	= ABSOLUTE ( _etext16 - _text16_late );
70
-    _text16_memsz	= ABSOLUTE ( _etext16 - _text16 );
66
+    _text16_early_filesz = ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 );
67
+    _text16_early_memsz	= ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 );
68
+    _text16_late_filesz	= ABSOLUTE ( _mtext16 ) - ABSOLUTE ( _text16_late );
69
+    _text16_late_memsz	= ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16_late );
70
+    _text16_memsz	= ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16 );
71 71
 
72 72
     /*
73 73
      * The 16-bit (real-mode) data section
@@ -89,8 +89,8 @@ SECTIONS {
89 89
 	*(.stack16.*)
90 90
 	_edata16 = .;
91 91
     }
92
-    _data16_filesz	= ABSOLUTE ( _mdata16 - _data16 );
93
-    _data16_memsz	= ABSOLUTE ( _edata16 - _data16 );
92
+    _data16_filesz	= ABSOLUTE ( _mdata16 ) - ABSOLUTE ( _data16 );
93
+    _data16_memsz	= ABSOLUTE ( _edata16 ) - ABSOLUTE ( _data16 );
94 94
 
95 95
     /*
96 96
      * The 32-bit sections
@@ -118,8 +118,8 @@ SECTIONS {
118 118
 	*(.stack.*)
119 119
 	_etextdata = .;
120 120
     }
121
-    _textdata_filesz	= ABSOLUTE ( _mtextdata - _textdata );
122
-    _textdata_memsz	= ABSOLUTE ( _etextdata - _textdata );
121
+    _textdata_filesz	= ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata );
122
+    _textdata_memsz	= ABSOLUTE ( _etextdata ) - ABSOLUTE ( _textdata );
123 123
 
124 124
     /*
125 125
      * Compressor information block
@@ -134,8 +134,8 @@ SECTIONS {
134 134
     } .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
135 135
 	_ezinfo = .;
136 136
     }
137
-    _zinfo_filesz	= ABSOLUTE ( _mzinfo - _zinfo );
138
-    _zinfo_memsz	= ABSOLUTE ( _ezinfo - _zinfo );
137
+    _zinfo_filesz	= ABSOLUTE ( _mzinfo ) - ABSOLUTE ( _zinfo );
138
+    _zinfo_memsz	= ABSOLUTE ( _ezinfo ) - ABSOLUTE ( _zinfo );
139 139
 
140 140
     /*
141 141
      * Weak symbols that need zero values if not otherwise defined

Loading…
Cancel
Save