I'm having some weird problems with my kernel;
if I put "char strWelcome[256] = "Welcome!"" on the top of my _start function, bochs panics.
PS:
I have created my own memset.
Dumb strings!
-
mystran
Re:Dumb strings!
That's probably because your compiler inserts the string right before the function. Now if you just start executing the image from the beginning, the first thing it tries to execute is the string.
There are (at least) three solutions. One is to tell your compiler to put the string into data-section (-fwritable-strings with gcc) and one is to write a small wrapper that just calls the actual startup function, and make sure that this wrapper is linked as the first thing..
Third solution is to use an executable format such as ELF which allows you to say where to start execution and a bootloader such as GRUB that respects this..
There are (at least) three solutions. One is to tell your compiler to put the string into data-section (-fwritable-strings with gcc) and one is to write a small wrapper that just calls the actual startup function, and make sure that this wrapper is linked as the first thing..
Third solution is to use an executable format such as ELF which allows you to say where to start execution and a bootloader such as GRUB that respects this..
- Pype.Clicker
- Member

- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Dumb strings!
Consider this as a quick patch. You may have other troubles like this one later by adding new functions, static variables and the like. The real solution consist of having the "jmp start" out of your C code, and of having a linker script that will enforce this instruction to come the very first in your kernel (if you keep a plain binary file).pytrood wrote: I tested with -fwritable-strings and it worked! Thanks alot![]()
Now, i have nothing wrong with quick patches. Just keep in mind for latter debugging.
Btw, i wonder if it could be feasible to put the "jmp start" in the linker script itself with something like
Code: Select all
BYTE(0xEA /* check intel manuals to make sure this is 'jmp' opcode);
LONG(_start) /* if _start is your entry point ;)