diff options
author | Luca Dariz <luca.dariz@gmail.com> | 2022-02-05 18:51:24 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-08-27 19:09:19 +0200 |
commit | f90ba97d5091ad85f089817231f53e34a0f6f259 (patch) | |
tree | 9586f5d9d0e11f508b150315b7466d5197726d56 /x86_64/ldscript | |
parent | f2626beb39dc416ceebfa35076d89cd291e2b903 (diff) | |
download | gnumach-f90ba97d5091ad85f089817231f53e34a0f6f259.tar.gz gnumach-f90ba97d5091ad85f089817231f53e34a0f6f259.tar.bz2 gnumach-f90ba97d5091ad85f089817231f53e34a0f6f259.zip |
add support for booting from grub with x86_64
* configure: compile for native x86_64 by default instead of xen
* x86_64/Makefrag.am: introduce KERNEL_MAP_BASE to reuse the constant
in both code and linker script
* x86_64/ldscript: use a .boot section for the very first operations,
until we reach long mode. This section is not really allocated, so
it doesn't need to be freed later. The vm system is later
initialized starting from .text and not including .boot
* link kernel at 0x4000000 as the xen version, higher values causes
linker errors
* we can't use full segmentation in long mode, so we need to create a
temporary mapping during early boot to be able to jump to high
addresses
* build direct map for first 4G in boothdr, it seems required by Linux
drivers
* add INTEL_PTE_PS bit definition to enable 2MB pages during bootstrap
* ensure write bit is set in PDP entry access rights. This only
applies to PAE-enabled kernels, mandatory for x86_64. On xen
platform it seems to be handled differently
Signed-off-by: Luca Dariz <luca@orpolo.org>
Message-Id: <20220205175129.309469-2-luca@orpolo.org>
Diffstat (limited to 'x86_64/ldscript')
-rw-r--r-- | x86_64/ldscript | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/x86_64/ldscript b/x86_64/ldscript index 375e8104..de99795e 100644 --- a/x86_64/ldscript +++ b/x86_64/ldscript @@ -2,7 +2,7 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") OUTPUT_ARCH(i386:x86-64) -ENTRY(_start) +ENTRY(boot_start) SECTIONS { /* @@ -11,22 +11,30 @@ SECTIONS * be first in there. See also `i386/i386at/boothdr.S' and * `gnumach_LINKFLAGS' in `i386/Makefrag.am'. */ - . = _START; - .text : - AT (_START_MAP) + + . = _START_MAP; + .boot : + { + *(.boot.text) + *(.boot.data) + } =0x90909090 + + . += KERNEL_MAP_BASE; + _start = .; + .text : AT(((ADDR(.text)) - KERNEL_MAP_BASE)) { - *(.text.start) + *(.text*) *(.text .stub .text.* .gnu.linkonce.t.*) *(.text.unlikely .text.*_unlikely) KEEP (*(.text.*personality*)) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) } =0x90909090 - .init : + .init : AT(((ADDR(.init)) - KERNEL_MAP_BASE)) { KEEP (*(.init)) } =0x90909090 - .fini : + .fini : AT(((ADDR(.fini)) - KERNEL_MAP_BASE)) { KEEP (*(.fini)) } =0x90909090 @@ -69,7 +77,7 @@ SECTIONS PROVIDE_HIDDEN (__rela_iplt_end = .); } .plt : { *(.plt) *(.iplt) } - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata : AT(((ADDR(.rodata)) - KERNEL_MAP_BASE)) { *(.rodata .rodata.* .gnu.linkonce.r.*) } .rodata1 : { *(.rodata1) } .eh_frame_hdr : { *(.eh_frame_hdr) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } @@ -139,7 +147,7 @@ SECTIONS .got : { *(.got) *(.igot) } . = DATA_SEGMENT_RELRO_END (24, .); .got.plt : { *(.got.plt) *(.igot.plt) } - .data : + .data : AT(((ADDR(.data)) - KERNEL_MAP_BASE)) { *(.data .data.* .gnu.linkonce.d.*) SORT(CONSTRUCTORS) @@ -147,7 +155,7 @@ SECTIONS .data1 : { *(.data1) } _edata = .; PROVIDE (edata = .); __bss_start = .; - .bss : + .bss : AT(((ADDR(.bss)) - KERNEL_MAP_BASE)) { *(.dynbss) *(.bss .bss.* .gnu.linkonce.b.*) |