OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Sep 20, 2020 3:59 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Strange linking problem
PostPosted: Thu Aug 18, 2005 9:22 am 
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...


Top
  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 10:16 am 
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


Top
  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 10:32 am 
Do I have to write at new bootsector ? Because my computer reboot when the bootsector jump to the kernel...


Top
  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 10:57 am 
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


Top
  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 10:58 am 
Allright... I'll try to figure out something...


Top
  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 11:09 am 
Mine...if it helps

Code:
[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:


Top
  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 1:19 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
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...


this is typical from incomplete linker script. See this other thread for details.

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:Strange linking problem
PostPosted: Thu Aug 18, 2005 10:55 pm 
Thanks Pype.Clicker. That helped ;)


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Monax and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group