While coding my IDT and GDT descriptor tables which were declared to be global i found out something very strange.
I have a structure named ExceptionGate so i declared 48 of them like this,
Code: Select all
struct ExceptionGate interrupts[48]={0};
correct?supposedly initialized data
However when i looked at the objdump of sections of the object file i found out this array was going into the bss section which already housed my stack and things went really ugly guys! Spent almost 3 days figuring out what i did wrong!
Finally i appeneded section attribute like this,
Code: Select all
struct ExceptionGate interrupts[48] __attribute__((section(".data")))={0};
So the question is do i've to this everytime i declare a global variable? Anyone else who has done similar thing to get data into correct segments?
These are my CFLAGS for make
Code: Select all
CFLAGS = -c -nostartfiles -nostdlib -nodefaultlibs -fno-builtin -Wall -ffreestanding -fno-common
Code: Select all
CPPFLAGS= -c -nostartfiles -nostdlib -nodefaultlibs -fno-builtin -Wall -ffreestanding -fno-rtti -fno-exceptions -nostdinc++ -fno-common
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]