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

Linus Torvalds
2011-02-17T17:45:37Z

[-- Attachment #1: Type: text/plain, Size: 858 bytes --]

On Thu, Feb 17, 2011 at 9:31 AM, Dmitry Torokhov <dtor@vmware.com> wrote:
>
> From what I understand __attribute__ ((aligned(x))) only guarantees
> minimum alignment, not exact (gapless) alignment. GCC seems to lay out
> pointers in the section without gaps on all arches that we have.

I still don't see the problem.

Have you actually _tried_ just adding the proper alignment to before
the __modver thing in include/asm-generic/vmlinux.lds.h ?

As far as I can tell, the bug is really simple:
- the section is not aligned
- but we told the compiler that that structure is aligned

End result: there is a gap between the section start and the first structure.

And the fix seems obvious: just make sure that the section is
sufficiently aligned.

IOW, why isn't the proper fix the obvious trivial one (attached)?

Linus

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 744 bytes --]

include/asm-generic/vmlinux.lds.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index fe77e33..31a4b1d 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -358,6 +358,7 @@
} \
\
/* Built-in module parameters. */ \
+ STRUCT_ALIGN() \
__param : AT(ADDR(__param) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start___param) = .; \
*(__param) \
@@ -365,6 +366,7 @@
} \
\
/* Built-in module versions. */ \
+ STRUCT_ALIGN() \
__modver : AT(ADDR(__modver) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start___modver) = .; \
*(__modver) \