Page 2 of 2

Re:OSKit and gcc 3.x

Posted: Fri Jul 22, 2005 6:05 am
by Freanan
LOL... kernel debugging - i had this before (trying to get into OSDev without using any oslibs - i got as far as having keyboard and timer interrupts. Failed at paging..)
but i hoped it would stop if i use a library of that kind - or at least when i boot the prewritten example kernel for testing purpose ;)

Re:OSKit and gcc 3.x

Posted: Sun Jul 24, 2005 11:48 pm
by Freanan
I tried to boot all the example kernels now, but the results do not vary very much. The only difference is that with some of the examples the multiboot-header-output is more complete than with others. But i did not do anything with the files and compiled them with the included makefile - so probably you all are right and i should go back to coding it all by myself.
The problem is, that everytime when i added much code to my previous kernels (like, adding 16 different exception handlers - without even inserting them into the idt) it would crash with an exception. So i had thought it might help to use a lib to setup a more or less secure environment...

Re:OSKit and gcc 3.x

Posted: Mon Jul 25, 2005 4:46 am
by distantvoices
welcome to debug sessions darker than night
mwaaahahahahaha

You are sure you've loaded everything into memory on your previous attempts?

error Nr. One if relying on own bootloader: not all sectors of the image are fetched, thus leading to a bamboozled cpu. :-)

Don't despair, lad. I've been there too. Crazy errors, not obvious, not easy to track down. I still have a few of them (well, that's due to some complicatedness in realms where no need for complicatedness exists.)

Re:OSKit and gcc 3.x

Posted: Mon Jul 25, 2005 5:26 am
by Freanan
I also thought about that problem - but as far as i remember i loaded more sectors then should have been needed.
-I should get back into my old code.
Or maybe i will start it all over again and use grub and write more tidy and clean code from the beginning this time...

Re:OSKit and gcc 3.x

Posted: Tue Jul 26, 2005 3:21 pm
by Freanan
I decided to start it all over again. I am (ab)using Code from "Brans Kernel Development Tutorial" right now, because the Tutorial does all the things that i have accomplished back in my previous efforts, just that it is way more elegant and it does not have the strange problem of crashing with a growing kernel.

Now i have new problems:

1. When i use the code unmodified, text output does not work.
(the chars from the keyboard-isr are shown as they should but the string from the message that is putch-ed is lost.) I assume this is a problem that has something to do with pointers, literal strings and the linker? I also believe it has been solved on this forum, but i could not find the old threads that i remember and don't remember what to do.
Text output was the only thing my previous attempts had working, which does not work in the tutorial code... but well, text output is kind of a nifty feature, so please help me on this ;)

2. I tried to add these lines in main, to verify my thoughts about problem 1:

Code: Select all

unsigned char* v=(unsigned char*) 0xb8000;
v[0]=67; //"C"
v[1]=10; //Light green
After trying to boot the modified kernel, grub complained about my kernel not having the right format anymore.
When i looked at my kernel-binary it indeed proved to have not the right format, because the data-section (ie all the constants), had been linked in before the text section and the start.o file with the multiboot-header.
I really wonder how this could happen just by adding three harmless lines, especially as i am using a linker script (provided by the tutorial as well).

Thanks in advance for help.
Of course i can also post any needed code or just a link to the Tutorial, if needed.

Re:OSKit and gcc 3.x

Posted: Tue Jul 26, 2005 6:06 pm
by AR
You need to add *(.rodata*) to the .text section of the linkscript. The 'invalid-ness' may also have been indirectly caused by this (LD tends to be a bit on the stupid side and links .rodata at 0 which messes everything up, if your kernel is in ELF then you can dump it and that'll probably be the problem)

Re:OSKit and gcc 3.x

Posted: Wed Jul 27, 2005 9:21 am
by Freanan
Both thinks work now - thank you very much :) !