OSDev.org
https://forum.osdev.org/

Strange linking problem
https://forum.osdev.org/viewtopic.php?f=1&t=10812
Page 1 of 1

Author:  Zioo [ Thu Aug 18, 2005 9:22 am ]
Post subject:  Strange linking problem

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...

Author:  DruG5t0r3 [ Thu Aug 18, 2005 10:16 am ]
Post subject:  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

Author:  Zioo [ Thu Aug 18, 2005 10:32 am ]
Post subject:  Re:Strange linking problem

Do I have to write at new bootsector ? Because my computer reboot when the bootsector jump to the kernel...

Author:  DruG5t0r3 [ Thu Aug 18, 2005 10:57 am ]
Post subject:  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

Author:  Zioo [ Thu Aug 18, 2005 10:58 am ]
Post subject:  Re:Strange linking problem

Allright... I'll try to figure out something...

Author:  DruG5t0r3 [ Thu Aug 18, 2005 11:09 am ]
Post subject:  Re:Strange linking problem

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:

Author:  Pype.Clicker [ Thu Aug 18, 2005 1:19 pm ]
Post subject:  Re:Strange linking problem

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.

Author:  Zioo [ Thu Aug 18, 2005 10:55 pm ]
Post subject:  Re:Strange linking problem

Thanks Pype.Clicker. That helped ;)

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/