]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Fix building on older versions of binutils
authorMichael Brown <mcb30@ipxe.org>
Fri, 19 Feb 2016 19:45:23 +0000 (19:45 +0000)
committerMichael Brown <mcb30@ipxe.org>
Fri, 19 Feb 2016 20:03:30 +0000 (20:03 +0000)
Some older versions of binutils have issues with both the use of
PROVIDE() and the interpretation of numeric literals within a section
description.

Work around these older versions by defining the required numeric
literals outside of any section description, and by automatically
determining whether or not to generate extra space for page tables
rather than relying on LDFLAGS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/scripts/pcbios.lds
src/arch/x86_64/Makefile.pcbios

index dccdfbed90b9980e8c9c1f38f1f0ccf851b72de6..c9a91c02be3ca41416ee5056526dd7b7b7b8d4cf 100644 (file)
@@ -27,10 +27,18 @@ SECTIONS {
     PROVIDE ( _max_align = 16 );
 
     /*
-     * Default to not generating space for page tables
+     * Values used in page table calculations
+     *
+     * On older versions of ld (without the SANE_EXPR feature),
+     * numeric literals within a section description tend to be
+     * interpreted as section-relative symbols.
      *
      */
-    PROVIDE ( _use_page_tables = 0 );
+    _page_size = 4096;
+    _page_size_1 = ( _page_size - 1 );
+    _pte_size = 8;
+    _pte_count = ( _page_size / _pte_size );
+    _pte_count_1 = ( _pte_count - 1 );
 
     /*
      * Allow decompressor to require a minimum amount of temporary stack
@@ -133,12 +141,18 @@ SECTIONS {
        *(COMMON)
        *(.stack)
        *(.stack.*)
+       _pages = .;
        *(.pages)
        *(.pages.*)
-       _textdata_paged_len = ABSOLUTE ( . - _textdata );
-       _textdata_ptes = ABSOLUTE ( ( _textdata_paged_len + 4095 ) / 4096 );
-       _textdata_pdes = ABSOLUTE ( ( _textdata_ptes + 511 ) / 512 );
-       . += ( _use_page_tables ? ( _textdata_pdes * 4096 ) : 0 );
+       _use_page_tables = ABSOLUTE ( . ) - ABSOLUTE ( _pages );
+       _textdata_paged_len =
+           ABSOLUTE ( ABSOLUTE ( . ) - ABSOLUTE ( _textdata ) );
+       _textdata_ptes =
+           ABSOLUTE ( ( _textdata_paged_len + _page_size_1 ) / _page_size );
+       _textdata_pdes =
+           ABSOLUTE ( ( _textdata_ptes + _pte_count_1 ) / _pte_count );
+       . += ( _use_page_tables ? ( _textdata_pdes * _page_size ) : 0 );
+       _epages = .;
        _etextdata = .;
     }
     _textdata_filesz   = ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata );
index 54bc0e4883b386dfd68030a3172f088e53ccc1a2..ba4c8d8dc0d22ffded8375866882b4f5015aa148 100644 (file)
@@ -9,10 +9,6 @@ LDFLAGS                += --section-start=.textdata=0xffffffffeb000000
 #
 CFLAGS         += -mno-red-zone
 
-# Generate extra space for page tables to cover .textdata
-#
-LDFLAGS                += --defsym=_use_page_tables=1
-
 # Include generic BIOS Makefile
 #
 MAKEDEPS       += arch/x86/Makefile.pcbios