At 18:45 15/09/00 +0200, Xavier DEBREUIL wrote:
 > Consider the following structure :
 > struct foo{
 >  u8 buf[5];
 >  u8 frame[0];
 > } ;

(snipped)
sizeof(foo) == 8 with arm-linux-gcc, or 5 with (x86?) gcc.

You are seeing that the minimum structure alignment is 4 for the ARM 
compiler, but 1 for the x86 gcc.

This is due to an historical optimisation choice, made for the original 
commercial ARM compiler.  Somebody thought they could compile faster code 
for ARM by making this restriction.  For example, you can use a word 
aligned memcpy for "foo" on ARM, but you have to use the generic version on 
x86.

I believe arm-gcc maintainers chose to do the same for object-level 
compatibility.

Unfortunately changing this breaks compatibility,  So if you change it for 
your own code, you may not be able to use some parts of glibc anymore. It 
could fail in bad ways. (Unless you recompile everything on your system 
yourself.)

ARM has changed this in our tool-chain, and we took a backwards 
compatibility hit when we did so.

So "arm-gcc" is not compatible with the ARM ADS tool-chain, as a result.

Phil - are there any plans to change this in a future gcc?

Efforts are still underway to document this as a standard.  Currently this 
is not part of either the ARM ATPCS or the ARM ELF specs, so it's not 
surprising there are compatibility problems.

There's a similar problem with 4 byte alignment of global variables.

 > Is there any option for the arm-linux-gcc to give the same result as the 
gcc ?

"-mstructure-size-boundary=8"  (for 1 byte = 8 bits alignment)

Be very careful with this, because it will break compatibility with some 
libraries, and other object files.

Cheers,

Michael Nonweiler.

(speaking for myself)


_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm

Reply via email to