Error: Entry point isn't in a segment
Posted: Sun Nov 30, 2014 2:25 pm
Hi!
I was trying to follow the wiki's Higher-Half tutorial. It looked too easy... Simple arithmetic and that's it. But when I compile and run all the stuff, GRUB 2.00 revenges again . A little message appears, saying:
And here's the relevant linker script:
The wiki says I shouldn't calculate the physical address of __start__ myself, or I'll get the mentioned error. But I'm not doing it
I was trying to follow the wiki's Higher-Half tutorial. It looked too easy... Simple arithmetic and that's it. But when I compile and run all the stuff, GRUB 2.00 revenges again . A little message appears, saying:
What am I doing wrong? I saw that in the tutorial, the .text section wasn't page-aligned. I did it, and the same error apperars. Then I saw the tutorial puts the Multiboot header in the .text section, but that's just awful and dangerous. I changed my code, just for test, and obviously a "multiboot not found" error appeared; undoed that. Here's the relevant code (in file /arch/x86/init/bootstrap.S):GRUB 2.00 wrote: error: entry point isn't in a segment.
error: you need to load the kernel first.
Press any key to continue...
Code: Select all
.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.align 0x1000
.section .stack, "aw", @nobits
stackBottom:
.skip 16384
stackTop:
.set KVIRT_BASE, 0xC0000000
.set KPAGE_NUM, (KVIRT_BASE >> 22)
.section .data
pageDirectory:
.long 0x00000083
.fill (KPAGE_NUM - 1), 4, 0x00000000
.long 0x00000083
.fill (1024 - KPAGE_NUM - 1), 4, 0x00000000
.section .text
.global __start__
.set __start__, (setup - 0xC0000000)
setup:
movl (pageDirectory - KVIRT_BASE), %eax
movl %ecx, %cr3
movl %cr4, %ecx
orl $0x00000010, %ecx
movl %ecx, %cr4
movl %cr0, %ecx
orl $0x80000000, %ecx
movl %ecx, %cr0
lea (realstart), %ecx
jmp *%ecx
realstart:
movl $0x00000000, (pageDirectory)
invlpg (0)
movl $stackTop, %esp
movl %esp, %ebp
push %ebx
push %eax
call KernelInit
cli
hlt
.hang:
jmp .hang
Code: Select all
ENTRY(__start__)
OUTPUT_FORMAT(elf32-i386)
SECTIONS {
. = 0xC0100000;
.text : ALIGN(0x1000) : AT(ADDR(.text) - 0xC0000000) {
*(.multiboot)
*(.text)
}
.rodata ALIGN(0x1000) : AT(ADDR(.rodata) - 0xC0000000) {
*(.rodata*)
}
.data ALIGN (0x1000) : AT(ADDR(.data) - 0xC0000000) {
*(.data)
}
.bss : AT(ADDR(.bss) - 0xC0000000) {
*(COMMON)
*(.bss)
*(.stack)
}
__KEND__ = .;
}