Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH] moduleparam: fix alpha, ia64 and ppc64 compile failures

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


ink at jurassic

Feb 8, 2008, 2:33 PM

Post #1 of 4 (174 views)
Permalink
[PATCH] moduleparam: fix alpha, ia64 and ppc64 compile failures

On alpha, ia64 and ppc64 only relocations to local data can go into
read-only sections. The vast majority of module parameters use the global
generic param_set_*/param_get_* functions, so the 'const' attribute for
struct kernel_param is not only useless, but it also causes compile
failures due to 'section type conflict' in those rare cases where
param_set/get are local functions.

This fixes http://bugzilla.kernel.org/show_bug.cgi?id=8964

Signed-off-by: Ivan Kokshaysky <ink[at]jurassic.park.msu.ru>
---
include/linux/moduleparam.h | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 8126e55..ec62438 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -62,6 +62,16 @@ struct kparam_array
void *elem;
};

+/* On alpha, ia64 and ppc64 relocations to global data cannot go into
+ read-only sections (which is part of respective UNIX ABI on these
+ platforms). So 'const' makes no sense and even causes compile failures
+ with some compilers. */
+#if defined(CONFIG_ALPHA) || defined(CONFIG_IA64) || defined(CONFIG_PPC64)
+#define __moduleparam_const
+#else
+#define __moduleparam_const const
+#endif
+
/* This is the fundamental function for registering boot/module
parameters. perm sets the visibility in sysfs: 000 means it's
not there, read bits mean it's readable, write bits mean it's
@@ -71,7 +81,7 @@ struct kparam_array
static int __param_perm_check_##name __attribute__((unused)) = \
BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \
static const char __param_str_##name[] = prefix #name; \
- static struct kernel_param const __param_##name \
+ static struct kernel_param __moduleparam_const __param_##name \
__used \
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
= { __param_str_##name, perm, set, get, { arg } }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo[at]vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


akpm at linux-foundation

Feb 8, 2008, 2:46 PM

Post #2 of 4 (157 views)
Permalink
Re: [PATCH] moduleparam: fix alpha, ia64 and ppc64 compile failures [In reply to]

On Sat, 9 Feb 2008 01:33:41 +0300
Ivan Kokshaysky <ink[at]jurassic.park.msu.ru> wrote:

> On alpha, ia64 and ppc64 only relocations to local data can go into
> read-only sections. The vast majority of module parameters use the global
> generic param_set_*/param_get_* functions, so the 'const' attribute for
> struct kernel_param is not only useless, but it also causes compile
> failures due to 'section type conflict' in those rare cases where
> param_set/get are local functions.
>
> This fixes http://bugzilla.kernel.org/show_bug.cgi?id=8964
>
> Signed-off-by: Ivan Kokshaysky <ink[at]jurassic.park.msu.ru>
> ---
> include/linux/moduleparam.h | 12 +++++++++++-
> 1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index 8126e55..ec62438 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -62,6 +62,16 @@ struct kparam_array
> void *elem;
> };
>
> +/* On alpha, ia64 and ppc64 relocations to global data cannot go into
> + read-only sections (which is part of respective UNIX ABI on these
> + platforms). So 'const' makes no sense and even causes compile failures
> + with some compilers. */
> +#if defined(CONFIG_ALPHA) || defined(CONFIG_IA64) || defined(CONFIG_PPC64)
> +#define __moduleparam_const
> +#else
> +#define __moduleparam_const const
> +#endif
> +
> /* This is the fundamental function for registering boot/module
> parameters. perm sets the visibility in sysfs: 000 means it's
> not there, read bits mean it's readable, write bits mean it's
> @@ -71,7 +81,7 @@ struct kparam_array
> static int __param_perm_check_##name __attribute__((unused)) = \
> BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \
> static const char __param_str_##name[] = prefix #name; \
> - static struct kernel_param const __param_##name \
> + static struct kernel_param __moduleparam_const __param_##name \
> __used \
> __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
> = { __param_str_##name, perm, set, get, { arg } }

I think it would have been better to define a new CONFIG_MODULEPARAM_CONST
for those three archictures, rather than muckying up the code like this.

But hey, I get to close a bugzilla report - I'm doing that amlonst monthly
now. Thanks.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo[at]vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


ink at jurassic

Feb 8, 2008, 3:35 PM

Post #3 of 4 (159 views)
Permalink
Re: [PATCH] moduleparam: fix alpha, ia64 and ppc64 compile failures [In reply to]

On Fri, Feb 08, 2008 at 02:46:15PM -0800, Andrew Morton wrote:
> I think it would have been better to define a new CONFIG_MODULEPARAM_CONST
> for those three archictures, rather than muckying up the code like this.

I'd prefer to keep this as is for now (sorta the uglier the better ;-)
I really hope it's the short term solution as we need some feedback from gcc
folks. We use named sections quite a lot, but gcc is sort of unfriendly with
these, and this particular problem is not the main one.
For instance, if someone dares to put a 'switch' statement into discarded
section (__exit), the final link fails (on any arch!), because gcc generates
a jump table in .rodata which references that discarded section...

Ivan.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo[at]vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


dsd at gentoo

Feb 9, 2008, 8:50 AM

Post #4 of 4 (146 views)
Permalink
Re: [PATCH] moduleparam: fix alpha, ia64 and ppc64 compile failures [In reply to]

Ivan Kokshaysky wrote:
> On alpha, ia64 and ppc64 only relocations to local data can go into
> read-only sections. The vast majority of module parameters use the global
> generic param_set_*/param_get_* functions, so the 'const' attribute for
> struct kernel_param is not only useless, but it also causes compile
> failures due to 'section type conflict' in those rare cases where
> param_set/get are local functions.
>
> This fixes http://bugzilla.kernel.org/show_bug.cgi?id=8964

In case you weren't aware already, people seem to think this is actually
a GCC bug (with a patch available):

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31490

Daniel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo[at]vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.