OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Sep 29, 2020 8:24 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: C++ Kernel Help needed
PostPosted: Mon Aug 09, 2004 2:27 pm 
Hi i'v been looking and reading and can't figure out what's wrong with my code
I followed a tutorial i've found at http://www.invalidsoftware.net/os/

but when i load my kernel i see that the bootloader
starts and then when he tries to jump to my code (Kernel)
it stoppes . But normaly it should print a message first
so i think the Bootloader doesn't find my Kernel or jump to the wrong startpoint pls i need help.

i attached my code in a zip file

BTW i found a gr8 tool wich all you guy should use if you use windows as your Development Platform it's colled bfi.exe
it creates floppy image from files so no messing around with floppy no more. check it out at

http://www.nu2.nu/bfi/

I hope someone can help me out here i'm very new at os dev so don't kill me if you see something stupid.


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Mon Aug 09, 2004 2:40 pm 
Here's the code i was talking about (in the attachement)
you'll should us download the small tool if you want to creat the image file with the makefile

the bfi.exe is located at http://www.nu2.nu/download.php?sFile=bfi10.zip


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Mon Aug 09, 2004 3:05 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
looks like you're missing .rodata sections in your linker script. I'm not sure whether it's relevant for your development platform or not ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Mon Aug 09, 2004 3:44 pm 
I read about .rodata it is where constanst or read only data is stored if i'm not mistaken. but i saw other linker script who don't use it either the on from the tutorial doesn't use it either

but in case i need it how do i implement it in my linker script????

and maybe a other question is there something wrong with the rest of the code???


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 1:30 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Errors exists in tutorial aswell (unfortunately). Or the tutorial you're reading may be targetted at another platform than yours.

I suggest you run "objdump -x <file.o>" on your intermediary files to see whether they have .rodata sections or not.

Depending on the policy you plan to have, you just input all ".rodata*" sections in either .text or .data sections. Everything that is not explicitly input'd in a script will not be present in the output file...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 1:57 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7469
Location: Germany
On a sidenote, how come that so many people combine the tutorial from invalidsoftware.net with our forum? I mean, we have our own BareBonesC++, and invalidsoftware.net has their own forum...

I'm not complaining, it just strikes me as odd...

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 2:13 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Solar wrote:
I'm not complaining, it just strikes me as odd...

Probably because we sent some many dudes towards invalidsoftware.net before BareBonesC++ was ready ... and that activity around here is much important ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 2:18 am 
hi thank for you reply olraedy but
i tried the thing you said and still get no changes.

this is my linker script now
but i don't get it right
stil don't get a message before the pc freezes

is there someone who can point me to a good tutorial on c++
kernels and how to boot them aswel since i think maybe thats problematic aswell

Code:
/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
    .text 0x100000 :
    {
        code = .; _code = .; __code = .;
        *(.text)
   *(.gnu.linkonce.t.*)        /* C++ templates? */
        *(.rodata*)                 /* read-only data (ELF only) */
   *(.gnu.linkonce.r.*)       
   . = ALIGN(4096);
    }

    .data :
    {
        __CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors)   LONG(0) __CTOR_END__ = .; 
        __DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .;

        data = .; _data = .; __data = .;
        *(.data)
        . = ALIGN(4096);
    }

    .bss :
    {
        bss = .; _bss = .; __bss = .;
        *(.bss)
        . = ALIGN(4096);
    }

    end = .; _end = .; __end = .;
}


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 6:17 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
Quote:
cc1plus: warning: "-ffreestanding" is valid for C/ObjC but not for C++

(editting makefile)
Quote:
ld -T link.ld -o kernel.bin loader.o kernel.o video.o support.o
loader.o(.text+0x1):loader.o: undefined reference to `__main'
loader.o(.text+0xb):loader.o: undefined reference to `__atexit'
make: *** [kernel.bin] Error 1

00000000 g F .text 00000039 __Z5_mainv
00000000 *UND* 00000000 __CTOR_LIST__
0000003a g F .text 00000039 __Z7_atexitv
00000000 *UND* 00000000 __DTOR_LIST__

Seems like we're missing an "extern C" here, or that gcc should be used instead of gxx (at least for my platform)...

Now i need a way to get the "BFI" thing working on Linux ...

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 6:52 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
now, hum, if i can afford a comment ...

you're kernel is 32 bits and your bootsector 16 bits ... How do you expect the processor to understand your wish ?

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 8:06 am 
i don't know i thout it woudn't matter since the bootloader should jump to my kernel

is there a bootloader out there whitch will boot my kernel????

or is it hard to change mine so it would boot my kernel??
i'm no assembler programmer so i'm not affraid to say i didn't write the bootloader myself i'm open to sugestions
i'm lookin into using grub but i'ts a pain in the @$$ to compile the thing on a windows os i'm don't have automake installed or configure scripts so i have to do it manualy


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 8:12 am 
Quote:

Now i need a way to get the "BFI" thing working on Linux ...



i don't know if it is ported to linux yet but if it isn't it should it's a great tool immediatly create images.

4im using vmware to test my os and i must say if didn't had the tool i would have given up already but testing go's so fast this way it's like i almost have my own INTEGRATED OS DEVELOPMENT ENVIRONMENT like that ;)


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Tue Aug 10, 2004 2:55 pm 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7469
Location: Germany
engine252 wrote:
i'm lookin into using grub but i'ts a pain in the @$$ to compile the thing on a windows os i'm don't have automake installed or configure scripts so i have to do it manualy


No need for that, dude! Check out the FAQ page on GRUB - there're precompiled versions readily available. Set up a GCC Cross-Compiler (easier than it sounds!), then wander to BareBones and BareBonesC++, and you're ready to rumble...

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Wed Aug 11, 2004 1:26 pm 
thx that's ll get me started
now just a few more years of reaging, programming ,learning
and searching.

BTW why is there so little info on C++ Kernel development????
it offers so much possibilities to have a object oriented Kernel

If you have some links on C++ Kernel articles just
send then here i'll be happy to look into them


Top
  
 
 Post subject: Re:C++ Kernel Help needed
PostPosted: Wed Aug 11, 2004 11:48 pm 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7469
Location: Germany
engine252 wrote:
BTW why is there so little info on C++ Kernel development????


Using C++ introduces a couple of additional requirements. Up until recently, there was no "standard" C++ ABI. Writing a C compiler is relatively easy, while a C++ compiler requires some serious work. C++ is the younger of the two languages. It is easier to write rather bad C++ code than doing the same folly in C.

C is the default language of kernel programmers; and most of the kernel gurus are so full of themselves that they never tire of spreading propaganda about C++. Just look at these two links to see how paranoid most kernel gurus react when you utter "C++":

http://kerneltrap.org/node/view/2067
http://www.tux.org/lkml/#s15-3

Note that I consider about 90% of the contra-C++ arguments to be complete bull, and the remaining 10% to be debatable. But I won't drag that out here; I already had some heated arguments with the LKML FAQ maintainers...

In the end, though, C is the much more popular language, and that's why there's so much material on "kernels in C" and so little on "kernels in {your-favourite-language}".

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: antoni, Majestic-12 [Bot] and 7 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