From: Michael Brown Date: Fri, 19 Feb 2016 19:45:23 +0000 (+0000) Subject: [build] Fix building on older versions of binutils X-Git-Tag: v1.20.1~580 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4923354e31f83c17b9c5befadb801b80c9f9cc1;p=thirdparty%2Fipxe.git [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 --- diff --git a/src/arch/x86/scripts/pcbios.lds b/src/arch/x86/scripts/pcbios.lds index dccdfbed9..c9a91c02b 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 54bc0e488..ba4c8d8dc 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