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