Strange pointer activity

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.
Post Reply
tuttlem
Posts: 2
Joined: Tue Jul 08, 2014 6:42 am

Strange pointer activity

Post 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?
tuttlem
Posts: 2
Joined: Tue Jul 08, 2014 6:42 am

Re: Strange pointer activity

Post 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!
Post Reply