[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>
pull/5/head
Michael Brown 2011-04-29 01:27:36 +01:00
parent 62c9635166
commit 987b825b7f
1 changed files with 13 additions and 13 deletions

View File

@ -39,8 +39,8 @@ SECTIONS {
} .bss.prefix (NOLOAD) : AT ( _end_lma ) {
_eprefix = .;
}
_prefix_filesz = ABSOLUTE ( _mprefix - _prefix );
_prefix_memsz = ABSOLUTE ( _eprefix - _prefix );
_prefix_filesz = ABSOLUTE ( _mprefix ) - ABSOLUTE ( _prefix );
_prefix_memsz = ABSOLUTE ( _eprefix ) - ABSOLUTE ( _prefix );
/*
* The 16-bit (real-mode) code section
@ -63,11 +63,11 @@ SECTIONS {
} .bss.text16 (NOLOAD) : AT ( _end_lma ) {
_etext16 = .;
}
_text16_early_filesz = ABSOLUTE ( _etext16_early - _text16 );
_text16_early_memsz = ABSOLUTE ( _etext16_early - _text16 );
_text16_late_filesz = ABSOLUTE ( _mtext16 - _text16_late );
_text16_late_memsz = ABSOLUTE ( _etext16 - _text16_late );
_text16_memsz = ABSOLUTE ( _etext16 - _text16 );
_text16_early_filesz = ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 );
_text16_early_memsz = ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 );
_text16_late_filesz = ABSOLUTE ( _mtext16 ) - ABSOLUTE ( _text16_late );
_text16_late_memsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16_late );
_text16_memsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16 );
/*
* The 16-bit (real-mode) data section
@ -89,8 +89,8 @@ SECTIONS {
*(.stack16.*)
_edata16 = .;
}
_data16_filesz = ABSOLUTE ( _mdata16 - _data16 );
_data16_memsz = ABSOLUTE ( _edata16 - _data16 );
_data16_filesz = ABSOLUTE ( _mdata16 ) - ABSOLUTE ( _data16 );
_data16_memsz = ABSOLUTE ( _edata16 ) - ABSOLUTE ( _data16 );
/*
* The 32-bit sections
@ -118,8 +118,8 @@ SECTIONS {
*(.stack.*)
_etextdata = .;
}
_textdata_filesz = ABSOLUTE ( _mtextdata - _textdata );
_textdata_memsz = ABSOLUTE ( _etextdata - _textdata );
_textdata_filesz = ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata );
_textdata_memsz = ABSOLUTE ( _etextdata ) - ABSOLUTE ( _textdata );
/*
* Compressor information block
@ -134,8 +134,8 @@ SECTIONS {
} .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
_ezinfo = .;
}
_zinfo_filesz = ABSOLUTE ( _mzinfo - _zinfo );
_zinfo_memsz = ABSOLUTE ( _ezinfo - _zinfo );
_zinfo_filesz = ABSOLUTE ( _mzinfo ) - ABSOLUTE ( _zinfo );
_zinfo_memsz = ABSOLUTE ( _ezinfo ) - ABSOLUTE ( _zinfo );
/*
* Weak symbols that need zero values if not otherwise defined