diff options
author | Michael Brown | 2016-02-19 20:45:23 +0100 |
---|---|---|
committer | Michael Brown | 2016-02-19 21:03:30 +0100 |
commit | a4923354e31f83c17b9c5befadb801b80c9f9cc1 (patch) | |
tree | 5f22049f24d3d018615162d95bd47ccc7f628c4a /src/arch | |
parent | [librm] Generate page tables for 64-bit builds (diff) | |
download | ipxe-a4923354e31f83c17b9c5befadb801b80c9f9cc1.tar.gz ipxe-a4923354e31f83c17b9c5befadb801b80c9f9cc1.tar.xz ipxe-a4923354e31f83c17b9c5befadb801b80c9f9cc1.zip |
[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>
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/scripts/pcbios.lds | 26 | ||||
-rw-r--r-- | src/arch/x86_64/Makefile.pcbios | 4 |
2 files changed, 20 insertions, 10 deletions
diff --git a/src/arch/x86/scripts/pcbios.lds b/src/arch/x86/scripts/pcbios.lds index dccdfbed..c9a91c02 100644 --- a/src/arch/x86/scripts/pcbios.lds +++ b/src/arch/x86/scripts/pcbios.lds @@ -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 ); diff --git a/src/arch/x86_64/Makefile.pcbios b/src/arch/x86_64/Makefile.pcbios index 54bc0e48..ba4c8d8d 100644 --- a/src/arch/x86_64/Makefile.pcbios +++ b/src/arch/x86_64/Makefile.pcbios @@ -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 |