I have a variable, initialEsp that I use to record the stack pointer as GRUB gives it (So I can move the stack elsewhere later in remapStack). Before, I had something like:
Code: Select all
initialEsp:
dd 0
--code here--
So I decided to try putting it in the .bss or .data sections - no joy, they get linked to some random location (0xf004 or something equally troublesome). So I tried declaring initialEsp in one of my .cc files and extern'ing it in my NASM boot file. No joy - ended up trying to write to 0x0 (I was observing the effects of these in objdump, as well as by trying to run the program).
In the end I opted for a major hack-o-rama:
Code: Select all
start: ;This is where all my multiboot stuff goes
dd 0 ; I added this line to reserve some space at 0x100000
dd MULTIBOOT BLEH
dd MULTIBOOT_MORE_BLEH
...
absolute 0x100000
initialEsp resw 2 ; initialEsp = 2 words (4 bytes) at 0x100000.
[SECTION .text] ; back to text section
--code--
anyone got any ideas? I assume FASM will work the same way.
Cheers
James