Re: Alignment Issue

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

 



jkayca <jeremy.kalvin@xxxxxxxxxxx> writes:

> 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.

What is the output of readelf -s on the .o file?  We only really need to
see the lines for myarray and myix.

Ian


[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