Browse Source

[build] Fix building on older versions of binutils

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>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
a4923354e3
2 changed files with 20 additions and 10 deletions
  1. 20
    6
      src/arch/x86/scripts/pcbios.lds
  2. 0
    4
      src/arch/x86_64/Makefile.pcbios

+ 20
- 6
src/arch/x86/scripts/pcbios.lds View File

27
     PROVIDE ( _max_align = 16 );
27
     PROVIDE ( _max_align = 16 );
28
 
28
 
29
     /*
29
     /*
30
-     * Default to not generating space for page tables
30
+     * Values used in page table calculations
31
+     *
32
+     * On older versions of ld (without the SANE_EXPR feature),
33
+     * numeric literals within a section description tend to be
34
+     * interpreted as section-relative symbols.
31
      *
35
      *
32
      */
36
      */
33
-    PROVIDE ( _use_page_tables = 0 );
37
+    _page_size = 4096;
38
+    _page_size_1 = ( _page_size - 1 );
39
+    _pte_size = 8;
40
+    _pte_count = ( _page_size / _pte_size );
41
+    _pte_count_1 = ( _pte_count - 1 );
34
 
42
 
35
     /*
43
     /*
36
      * Allow decompressor to require a minimum amount of temporary stack
44
      * Allow decompressor to require a minimum amount of temporary stack
133
 	*(COMMON)
141
 	*(COMMON)
134
 	*(.stack)
142
 	*(.stack)
135
 	*(.stack.*)
143
 	*(.stack.*)
144
+	_pages = .;
136
 	*(.pages)
145
 	*(.pages)
137
 	*(.pages.*)
146
 	*(.pages.*)
138
-	_textdata_paged_len = ABSOLUTE ( . - _textdata );
139
-	_textdata_ptes = ABSOLUTE ( ( _textdata_paged_len + 4095 ) / 4096 );
140
-	_textdata_pdes = ABSOLUTE ( ( _textdata_ptes + 511 ) / 512 );
141
-	. += ( _use_page_tables ? ( _textdata_pdes * 4096 ) : 0 );
147
+	_use_page_tables = ABSOLUTE ( . ) - ABSOLUTE ( _pages );
148
+	_textdata_paged_len =
149
+	    ABSOLUTE ( ABSOLUTE ( . ) - ABSOLUTE ( _textdata ) );
150
+	_textdata_ptes =
151
+	    ABSOLUTE ( ( _textdata_paged_len + _page_size_1 ) / _page_size );
152
+	_textdata_pdes =
153
+	    ABSOLUTE ( ( _textdata_ptes + _pte_count_1 ) / _pte_count );
154
+	. += ( _use_page_tables ? ( _textdata_pdes * _page_size ) : 0 );
155
+	_epages = .;
142
 	_etextdata = .;
156
 	_etextdata = .;
143
     }
157
     }
144
     _textdata_filesz	= ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata );
158
     _textdata_filesz	= ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata );

+ 0
- 4
src/arch/x86_64/Makefile.pcbios View File

9
 #
9
 #
10
 CFLAGS		+= -mno-red-zone
10
 CFLAGS		+= -mno-red-zone
11
 
11
 
12
-# Generate extra space for page tables to cover .textdata
13
-#
14
-LDFLAGS		+= --defsym=_use_page_tables=1
15
-
16
 # Include generic BIOS Makefile
12
 # Include generic BIOS Makefile
17
 #
13
 #
18
 MAKEDEPS	+= arch/x86/Makefile.pcbios
14
 MAKEDEPS	+= arch/x86/Makefile.pcbios

Loading…
Cancel
Save