flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Linking a 64 bit kernel

Author
Thread Post new topic Reply to topic
AnonymousUser



Joined: 25 Jul 2014
Posts: 32
AnonymousUser 12 Aug 2014, 02:22
Sorry if I have been posting a lot of questions guys I'm a little new to OS Dev
Anyway I was having trouble linking my C++ kernel to my assembly part of the kernel It links it without any errors but It looks like It is not loading it at the proper address here is the linker script:
Code:
KernAddr = 0x2000;
ENTRY(_Start)
SECTIONS
{
    . = KernAddr;

    .text : AT(ADDR(.text) - KernAddr)
    {
        _code = .;
        *(.text)
        *(.rodata*)
        . = ALIGN(4096);
    }

   .data : AT(ADDR(.data) - KernAddr)
   {
        _data = .;
        *(.data)
        . = ALIGN(4096);
   }

   .eh_frame : AT(ADDR(.eh_frame) - KernAddr)
   {
       _ehframe = .;
       *(.eh_frame)
        . = ALIGN(4096);
   }

   .bss : AT(ADDR(.bss) - KernAddr)
   {
       _bss = .;
       *(.bss)

       /*
        * You usually need to include generated COMMON symbols
        * under kernel BSS section or use gcc's -fno-common
        */

        *(COMMON)
       . = ALIGN(4096);
   }

   _end = .;

   /DISCARD/ :
   {
        *(.comment)
   }
}
    

This is the version of the bin utils I use and how I link it:
Code:
GNU ld (GNU Binutils) 2.24
x86_64-elf-ld -T linkerscript.ld -o Anmu.bin Stage2.o kernel.o -nostdlib
    


The full source code is available here: https://github.com/AnonymousUser1337/Anmu if you need to take a look at it.

_________________
Thanks in advance
Post 12 Aug 2014, 02:22
View user's profile Send private message Reply with quote
AnonymousUser



Joined: 25 Jul 2014
Posts: 32
AnonymousUser 12 Aug 2014, 19:47
My mistake again I forgot to change the file name length
Post 12 Aug 2014, 19:47
View user's profile Send private message Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 339
Location: Asia, Singapore
sid123 13 Aug 2014, 09:18
Do you first call the constructors before calling kmain, since it's C++? Also, remember that the compiler assumes that C++ runtime support is present. So do you pass -fno-rtti and -fno-exceptions to the compiler before linking? Also post the exact problem, "not loading the proper address" sounds pretty vague to me.
Post 13 Aug 2014, 09:18
View user's profile Send private message Reply with quote
AnonymousUser



Joined: 25 Jul 2014
Posts: 32
AnonymousUser 18 Aug 2014, 01:29
sid I am still reading up on how to call the constructors for now I am just using one file any help with that would be great
Thanks in advance Anonymous user
Post 18 Aug 2014, 01:29
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.