I have a kernel written in C and some header file that includes : stdio.h and some of other little things..
my problem : when i assign a value as initial value to a global variable, that won't work.
i used from gcc as my compiler and the process of compilation of my OS follows these steps :
1. compiling header files :
I separated header file into two file (i.e. one as foo.h and other as foo.c) then i compile that as object file :
Code: Select all
gcc -ffreestanding -c foo.c -o foo.o -m32Code: Select all
gcc -ffreestanding -c kernel.c -o kernel.o -m32
nasm -f elf Loader.asm -o Loader.oCode: Select all
ld -o OS.bin -Ttext 0x7c00 Loader.o Kernel.o foo.o --oformat binary -m elf_i386Code: Select all
#include "foo.h"
uint8_t Color = 0x14;
....
is there any way to initial global variable in way that works with no problem.
i checked my foo.o (object file), there are only .text Section.
Excuse me, Another Question : is there any way to avoid from compiling headers *.c file in compilation process ? some thing like using "stdio.h" in C coding in linux ?
thank you,



