Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
What is the datatype of "Test"? Is it a char*, a const char*, an unsigned char*, or what? I'm having a hard time implementing puts(). (I've got putch... so far all my OS does is print "x" on the screen. Not much, but...
Just do some test, i.e write a function that excepts a char * and see if you can call it, if it works, than it's a char *, if not try const char *. etc
Microsoft: "let everyone run after us. We'll just INNOV~1"
It is a "const char*". Try putting a string literal into a function that accepts a char* parameter and you'll get a warning on G++ something like "Deprecated implicit conversion from const char* to char*".
it compiles successfully, but GRUB tells me something about the executable format not being supported. This leads me to think it didn't really compile successfully, it just thought it did. What's wrong?
it compiles successfully, but GRUB tells me something about the executable format not being supported. This leads me to think it didn't really compile successfully, it just thought it did. What's wrong?
That has nothing to do with the executable format. Does GRUB work without that compiled in? Have you tried removing all code from that function until something breaks?
No, I do not have any rodata section in my linker script. Before someone tells me, let me guess (correct me if I'm wrong) - is rodata "read only data?" Because that would explain why initializing a const char* with " " would not work. (consts are read-only.)
JamesM wrote:
That has nothing to do with the executable format. Does GRUB work without that compiled in? Have you tried removing all code from that function until something breaks?
I tested this, what doesn't work is the actual call to puts(). (See below for insight)
ubergeek wrote:No, I do not have any rodata section in my linker script. Before someone tells me, let me guess (correct me if I'm wrong) - is rodata "read only data?" Because that would explain why initializing a const char* with " " would not work. (consts are read-only.)
So how do I add rodata to my linker script?
Well yes, string go to .rodata by default (there's -fwritable-strings in gcc for forcing them into .data but that's not necessarily a good idea).
You can add .rodata into your script just like any other section. I forexample just use:
Wait wait wait! My mistake, I actually was linking with an older linker script, with the new one (with the rodata section) it works great! Now my kernel prints "Hello World!" instead of 'x'.
np. As a completely shameless plug, if you'd have copied the linker script from my tutorials you wouldn't have had that problem (it has .rodata in already)!
Thanks, but actually, I was using a linker script from Bran's Kernel Development Tutorial (see the article in the wiki on its errors which, if I had seen first, would have made this post redundant). But your printing to the screen function worked great for me.