Re: gcc 4.5 and TLS
On Sat, Jun 5, 2010 at 00:52, Richard Zidlicky <email@example.com> wrote:
> On Fri, Jun 04, 2010 at 10:57:50PM +0200, Geert Uytterhoeven wrote:
>> On Fri, Jun 4, 2010 at 21:15, Thorsten Glaser <firstname.lastname@example.org> wrote:
>> > Andreas Schwab dixit:
>> >>One cost is ABI breakage.
>> > Hrm, that is true. But then: is that syscall/structure used already?
>> > I think I get an idea of the trouble though…
>> > On the other hand, changing gcc’s default alignment may break
>> > the ABI as well, no?
>> >>Also, I'm not yet convinced this works in all
>> >>situations, like for locks allocated on stack.
>> > That may not work, yes, since gcc is brain-dead and assumes that
>> > the stack is already aligned “properly”. What is the default stack
>> > alignment on m68k (in real life, not by some ABI)? If it’s 4, I
>> > think it shouldn’t be a problem.
>> It's 2. Even if you push a byte to the stack, the SP will be aligned to
>> an even address.
> this is the hardware behaviour but the compiler is free to use more alignment
> and it does that. At least for function calls I am pretty sure the minumum is
> guaranteed to be 4 bytes.
> This is because for function calls the compiler must work work with the
> assumption that the function may be invoked without a proper prototype
> declaration from an external module (which is hackish but perfectly legal
> in K&R) and for this reason K&R mandates a storage size that is large enough
> to accomodate both long or pointer.
And the alignment rules for long and pointer are 2-byte alignment...
IIRC, on Coldfire the stack is always 4-byte aligned.
> However I am not sure if automatic variable allocation on the stack is 4 bytes
> Even if it was not I am pretty sure it would not require an incompatible change
> of the ABI to guarantee 4 bytes stack alignment. It would also have close to zero
> effect on runtime performance and memory usage.
> The big ABI change that was discussed some time ago would have involved lot
> more - increasing the alignment of elements inside structs and alignment of
> array elements. Especially the struct alignment change would break plenty
> of stuff.
> I am not sure what happens if the futex is inside a "misaligned struct" - would
> that be handled with an attribute of the futex?
Changing the alignment rule for 32-byte quantities indeed has impact on structs.
But most other architectures need 4-byte alignment anyway.
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- email@example.com
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds