I have a file like this:
char* vidmem = (char*)0xb8000;
int main()
{
vidmem[0] = 'x';
vidmem[1] = 0x0f;
}
But when i compile it with gcc it behave like vidmem does not even exist. I have this problem with all variable declared outside of function. Maby this one can be declare inside main but other variables in other files linked to this can't be.
This how I compile it:
gcc -c main.c -o main.obj -ffreestanding -fno-exceptions -m64
And this is how i assemble all the files:
gcc -m64 -Wl,--build-id=none -static -fno-asynchronous-unwind-tables -nostdlib -nodefaultlibs -lgcc main.obj [..] -T linker.ld -o out.bin
Why this happen? And how can i solve it?
EDIT:
I am making an OS and this is the code from the C kernel. I am using linux subsystem for windows to compile it and qemu for testing
Here is a link to all the code: http://www.mediafire.com/file/7x21lh4dnc93dz9/OS.7z/file
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…