.align 2 is wrong; this should be .align 3. Vanilla FSF GCC 4.4.4 gets this correct, so it does look like a Linaro GCC bug after all.
Interestingly enough, the bug only happens with C++ class static variables; for "normal" global variables, the alignment attribute is respected correctly. Looking into GCC now ...
Hmm ... actually there *is* code in the Mozilla sources to attempt to ensure proper alignment, in jsstr.cpp:
#ifdef __SUNPRO_CC
#pragma pack(8)
#else
#pragma pack(push, 8)
#endif
JSString JSString: :unitStringTabl e[]
#ifdef __GNUC__
__attribute__ ((aligned (8)))
#endif
= {
U(0x00), U(0x01), U(0x02), U(0x03), U(0x04), U(0x05), U(0x06), U(0x07),
However, the compiler does not respect the attribute.
Minimal test case is:
struct JSString
{
unsigned int mLength;
static JSString unitStringTable[];
};
#pragma pack(push, 8) :unitStringTabl e[] __attribute__ ((aligned (8))) = { 1 };
JSString JSString:
#pragma pack(pop)
Building this with g++ -S results in:
.global _ZN8JSString15u nitStringTableE nitStringTableE , %object nitStringTableE , 4 nitStringTableE :
.data
.align 2
.type _ZN8JSString15u
.size _ZN8JSString15u
_ZN8JSString15u
.word 1
.align 2 is wrong; this should be .align 3. Vanilla FSF GCC 4.4.4 gets this correct, so it does look like a Linaro GCC bug after all.
Interestingly enough, the bug only happens with C++ class static variables; for "normal" global variables, the alignment attribute is respected correctly. Looking into GCC now ...