[PVFS-users] Re: "insmod fails" after kernel compilation with gcc 3.4.X

Rob Ross rross at mcs.anl.gov
Thu Jul 29 09:40:09 EDT 2004


I've applied the patch because I have a feeling this will come up a lot.

Thanks!

Rob

On Mon, 26 Jul 2004, Murali Vilayannur wrote:

> 
> Hi,
> I am not sure what the right solution is here. Rob can help decide 
> that. The problem with gcc 3.4.X is that the compiler is very "smart"
> in throwing out what it considers are dead-code and dead-data. 
> 
> The definitions of MODULE_LICENSE(),
> __module_kernel_version[], __module_using_checksums[]
>  from linux/module.h on 2.4 kernels look like this,
> 
> #define MODULE_LICENSE(license)  \
> static const char __module_license[]
> __attribute__((section(".modinfo"))) =   \
> "license=" license
> 
> static const char __module_kernel_version[] 
> __attribute__((section(".modinfo"))) =
> "kernel_version=" UTS_RELEASE;
> 
> #ifdef MODVERSIONS
> static const char __module_using_checksums[] 
> __attribute__((section(".modinfo"))) =
> "using_checksums=1";
> #endif
> 
> The compiler notices that none of these 3 variables are referenced (it 
> has no clue that these are the symbols that insmod looks for!!) and it 
> eliminates them. One option is to fix your headers like so,
> 
> static const char __module_license[] __attribute_used__ 
> __attribute__((section(".modinfo"))) =   \
> "license=" license
> 
> static const char __module_kernel_version[] __attribute_used__ 
> __attribute__((section(".modinfo"))) =
> "kernel_version=" UTS_RELEASE;
> 
> #ifdef MODVERSIONS
> static const char __module_using_checksums[] __attribute_used__
> __attribute__((section(".modinfo"))) =
> "using_checksums=1";
> #endif
> 
> where the __attribute_used__ is a macro that should be present in most 
> recent 2.4 kernels and if not it is as follows,
> 
> #if __GNUC__ > 3
> #define __attribute_used__ __attribute((__used__))
> #elif __GNUC__ == 3
> #if  __GNUC_MINOR__ >= 3
> # define __attribute_used__   __attribute__((__used__))
> #else
> # define __attribute_used__   __attribute__((__unused__))
> #endif /* __GNUC_MINOR__ >= 3 */
> #elif __GNUC__ == 2
> #define __attribute_used__ __attribute__((__unused__))
> #else
> #define __attribute_used__ /* not implemented */
> #endif /* __GNUC__ */
> 
> If you recompile the pvfs-kernel code after fixing these 3 definitions in 
> linux/module.h, you should be able to load and use the pvfs kernel module.
> NOTE that we don't have to fix MODULE_AUTHOR, MODULE_DESCRIPTION since 
> those macros evaluate to a "const char" and not a "static const char".
> 
> The other option is the attached patch (where we don't assume whether or 
> not the kernel headers are broken, whether or not gcc 3.4.x is used).
> In the worst case this patch would add 3 new symbols to the .modinfo 
> section of the object file, (i.e if the kernel headers are not broken).
> Hence this approach should work in all scenarios or so I think.
> Let us know if this patch fixes your problems.
> 
> Thanks,
> Murali
> 
> 
> On Sun, 25 Jul 2004, E. Otto wrote:
> 
> > I am not sure if the error is something else but after applying
> > the patch for gcc340 to the pvfs-kernel source (v 1.6.2), the 
> > compilation succeeds.  However, attempt to insert module pvfs.o 
> > complains that it can't find the kernel module. The RedHat Kernel in use 
> > is  2.4.20-30.9.
> > The module copied to the kernel fs directory is the one generated after 
> > the compilation. The messages are as shown:
> > 
> > [root at prahba ekw]# insmod pvfs
> > Using /lib/modules/2.4.20-30.9/kernel/fs/pvfs/pvfs.o
> > /lib/modules/2.4.20-30.9/kernel/fs/pvfs/pvfs.o: couldn't find the kernel 
> > version the module was compiled for
> > 
> > _______________________________________________
> > PVFS-users mailing list
> > PVFS-users at www.beowulf-underground.org
> > http://www.beowulf-underground.org/mailman/listinfo/pvfs-users
> > 
> > 


More information about the PVFS-users mailing list