From a4988195ce40182cd2491d6779b785a311d0e85a Mon Sep 17 00:00:00 2001 From: WangRunji Date: Sun, 15 Apr 2018 20:57:27 +0800 Subject: [PATCH] Fix kernel remap by fixing section name & linker. --- src/arch/x86_64/boot/boot.asm | 6 +++--- src/arch/x86_64/boot/linker.ld | 13 +++++++------ src/arch/x86_64/boot/long_mode_init.asm | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/arch/x86_64/boot/boot.asm b/src/arch/x86_64/boot/boot.asm index cc5dca3..40cd6e0 100644 --- a/src/arch/x86_64/boot/boot.asm +++ b/src/arch/x86_64/boot/boot.asm @@ -1,7 +1,7 @@ global start extern long_mode_start -section .text32 +section .text bits 32 start: mov esp, stack_top @@ -149,7 +149,7 @@ error: mov byte [0xb800a], al hlt -section .bss32 +section .bss align 4096 p4_table: resb 4096 @@ -161,7 +161,7 @@ stack_bottom: resb 4096 * 4 stack_top: -section .rodata32 +section .rodata gdt64: dq 0 ; zero entry .code: equ $ - gdt64 ; new diff --git a/src/arch/x86_64/boot/linker.ld b/src/arch/x86_64/boot/linker.ld index 86d17ec..3f145d2 100644 --- a/src/arch/x86_64/boot/linker.ld +++ b/src/arch/x86_64/boot/linker.ld @@ -6,21 +6,22 @@ KERNEL_OFFSET = 0xffffff0000000000; SECTIONS { . = BOOT_OFFSET; - .rodata32 : + .rodata.32 : { /* ensure that the multiboot header is at the beginning */ KEEP(*(.multiboot_header)) - *(.rodata32 .rodata32.*) + */boot.o (.rodata) . = ALIGN(4K); } - .text32 : + .text.32 : { - *(.text32 .text32.*) + */boot.o (.text) + */long_mode_init.o (.text) . = ALIGN(4K); } - .bss32 : + .bss.32 : { - *(.bss32 .bss32.*) + */boot.o (.bss) . = ALIGN(4K); } diff --git a/src/arch/x86_64/boot/long_mode_init.asm b/src/arch/x86_64/boot/long_mode_init.asm index e0b4a0c..f277f46 100644 --- a/src/arch/x86_64/boot/long_mode_init.asm +++ b/src/arch/x86_64/boot/long_mode_init.asm @@ -3,7 +3,7 @@ extern rust_main KERNEL_OFFSET equ 0xffff_ff00_0000_0000 -section .text32 +section .text bits 64 long_mode_start: ; load 0 into all data segment registers