Re: [PATCH 1/3] module: deal with alignment issues in built-in module versions

David Miller
2011-02-17T21:00:39Z

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Thu, 17 Feb 2011 10:06:40 -0800

> David, why are you saying that regular "just mark the structure
> alignment correctly" doesn't work?

Because it's been proven to not work:

http://marc.info/?l=linux-kernel&m=129674396021733&w=2
http://marc.info/?l=linux-kernel&m=129674399621795&w=2
http://marc.info/?l=linux-kernel&m=129674396121739&w=2
http://marc.info/?l=linux-kernel&m=129674396021735&w=2

GCC is very clever with "static" objects these days.

It thinks that, because you mark something "static", it can align it
any way it wants because it controls the domain in which the object
exists. It "knows" that the object can't be part of an array, and
therefore no external entity can be concerned about the true "size" of
the object (specifically wrt. side effects of the alignment of the
object).

In these cases it takes the explicit alignment attribute as a minimum,
not as an absolute requirement.

But we lie to the compiler, we mark things static then put them into a
special a special section, then try to iterate over those objects
globally as an array and expect the compiler to lay them all out
with identical alignments and sizes everywhere.

And this doesn't work.