Alignment Issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I have a problem I hope that someone can help me out with.

I have a the following static variable: Note that it is aligned on a 4KB
boundary via the 'aligned' attribute.

	typedef struct mystruct_s { unsigned int entry[1024]; } mystruct_t;
	static mystruct_t myarray __attribute__ ((aligned (4096)));

I have another static that is used as an index into this array.

	static unsigned int myix;

Both the myarray and myix are used by several of the functions in the module
and therefore declared outside the scope of any function. However, they are
not needed outside said module. Hence the static declaration.

When I compile my module I see myarray placed on a 4KB boundary (which is
good). I also see myix aligned on a 4KB boundary (which is bad).

I also have other static variables. None of these are aligned on anything
but their natural alignment.

I'm targeting the i386 architecture and I think the version of gcc is 4.5.1.

Anyone know what's going on? BTW, if I change the declaration of myix to
include an initializer than everything is fine. I guess because myix gets
pushed out of the BSS and into the COM section.

Thanks,

-- 
View this message in context: http://old.nabble.com/Alignment-Issue-tp32584295p32584295.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux