This is now my third loosely related question to memory management. Thanks for the quick help on the other posts!
This question is pretty quick to ask in comparison:
In my kernel, if I go something like:
int x; vid.writeln((unsigned long)&x)
I invariably get a number around 0x1000 which is confusing - I have 3 sections in my linker script, text (loaded at 0xc0000000), data, which according to a symbol I defined inside it, is loaded shortly after, and bss, which again is loaded just after that again. Obviously this isn't good when it comes to multitasking - I'd really prefer all the kernel data to be above the 3GB mark. I've read the ld manual, and I'm sure the link.ld file I use is ok. So can anyone suggest what I can look at to try and fix this?
Thanks!
linking the kernel: Where are my variables?
Re:linking the kernel: Where are my variables?
If x is a local variable, it gets put on the stack. So the address of x will depend on where the stack is, which in turn depends on the value of ESP when the thread is created (or on what value you assign to ESP when the kernel boots). Clearly each thread needs its own stack, since each thread has its own local variables and call frame.
Re:linking the kernel: Where are my variables?
Aha! That would explain everything very nicely. Thanks!