GCC Segment issue

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pranjas
Member
Member
Posts: 25
Joined: Sun Jan 16, 2011 9:18 pm

GCC Segment issue

Post by pranjas »

Hi,

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};
GCC does gives a warning but this is
supposedly initialized data
correct?

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};
which did worked indeed.

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
and CPPFLAGS as

Code: Select all

CPPFLAGS= -c -nostartfiles -nostdlib -nodefaultlibs -fno-builtin -Wall -ffreestanding -fno-rtti -fno-exceptions -nostdinc++ -fno-common
I'm using
gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]
Post Reply