Page 1 of 1

Strange pointer activity

Posted: Sat Jul 12, 2014 9:47 am
by tuttlem
Hi all,

Using the code in this wiki article as a base (http://wiki.osdev.org/64-bit_Higher_Hal ... ith_GRUB_2), I've now landed in C land to start putting together my Kernel.

I'm just struggling at the moment with data that I define. With a simple console_write function (I think it came from JamesM's kernel tutes), I've started attempting to write strings to the console. In my main() function, I have these two following string declarations:

Code: Select all

const char *x = "foo";
char s[] = "bar";
Passing the string "s" works, but "x" doesn't! Using a very round-a-bout way, I've tried to establish the address differences between these two variables. "x" points at 0xffffffff8010e000 and "s" points at 0xffffffff8010bfda.

Do I have extra memory paging work to conduct to get this working?

Re: Strange pointer activity

Posted: Sat Jul 12, 2014 10:34 pm
by tuttlem
After a fair bit of hair pulling, I finally have some sanity with regards to my issue. In my Makefile, I needed to change my linker flags from this

Code: Select all

-nodefaultlibs
to this . . .

Code: Select all

-nostdlib -z nodefaultlib -z max-page-size=0x1000
My pointers that I declare in C are now containing the data that they should!