I'm developing a new OS (the old one was gone, when my harddisk crashed). And i've finished the video functions and so on. But now i have a strange problem.. If I add a new file named idt.c (the name doesn't matter) and compile it with gcc, the same way as the other files and link it the file into the kernel.. Then my kernel.bin is 1 MB in size. Before it was 12 KB :-\ it doesn't matter if the file is empty or it contains data.. same result...
I'm using GCC 3.4.3 under Mandriva Linux 10.2..
Can somebody tell me what there can be wrong ? I'm really lost right now...
Strange linking problem
Re:Strange linking problem
I had that same problem before, I almost bashed my head on my screen a few times because of it....
It's because you are linking the kernel in binary, you should change all that in elf. Besides...everything is just so much better in elf format =P
It's because you are linking the kernel in binary, you should change all that in elf. Besides...everything is just so much better in elf format =P
Re:Strange linking problem
Do I have to write at new bootsector ? Because my computer reboot when the bootsector jump to the kernel...
Re:Strange linking problem
you don't need to completely rewrite it, but a few changes have to be done...Sorry If I can't give you much more info...I'm at work....Shhhh =P....My source code isn't here
Re:Strange linking problem
Mine...if it helps
Code: Select all
[BITS 32]
global start
start:
mov esp, stack ; Sets up stack
jmp kernelboot
ALIGN 4
.mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN _code, _bss, _end
; This is the GRUB Multiboot header. A boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge - must be physical addresses. Make a note of these:
; The linker script fills in the data for these ones!
dd .mboot
dd _code
dd _bss
dd _end
dd start
kernelboot:
push eax ; Passes the grub info to kernel.c
push ebx
extern kmain
call kmain ; Call kernel.c
cli ; stop interrupts
jmp $
; Looks like bochs doesn't like a hlt instruction with IF=0
;hlt ; stops CPU and we're dead in the water.
global idt_load
extern idtr
idt_load:
lidt [idtr]
ret
; Stack
SECTION .bss
resb 8192
stack:
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Strange linking problem
this is typical from incomplete linker script. See this other thread for details.Zioo wrote: Then my kernel.bin is 1 MB in size. Before it was 12 KB :-\ it doesn't matter if the file is empty or it contains data.. same result...