unexpected bahavior with module - relocation problem ?
Matthias Fuchs
matthias.fuchs at esd-electronics.com
Wed May 8 19:47:13 EST 2002
Hi,
I found the problem. It seems to be a problem with the insmod tool in the busybox
that I am using on my target (0.61pre from cvs).
Matthias
Matthias Fuchs wrote:
>
> Hi all,
>
> I got a little problem that I cannot really understand.
> I wrote a little device driver for a 405 PPC board. The driver registers
> a miscdevice.
>
> Normally all misc devices are listed under /proc/misc.
> My first attempt resulted in a /proc/misc looking like this:
>
> # cat /proc/misc
> 187 <- "test" is missing here !
> 185 gpio
>
> The code is attached. When I change the init stuff for the miscdevice
> structure
> a little bit (see below with WORKING defined), I got the expected bahavior.
>
> Is this a relocation problem when loading the module ? In the two
> version the NAME string
> sits in different segments. Is there a way to fix the problem by a
> compiler switch ? Is this a PPC issue ?
> I noticed that the Linux rtc driver uses the same code as I do, but it
> does not have the problem.
> The difference is that my code is a lkm and mot compiled into the kernel.
>
> Matthias
>
> ...
>
> #define NAME "test"
> #define MINOR 187
>
> #ifdef WORKING
> static char name[]=NAME;
> #endif
>
> static struct file_operations my_fops =
> {
> ...
> };
>
> static struct miscdevice my_miscdev =
> {
> #ifdef WORKING
> name: name, // results in correct bahavior
> #else
> name: NAME, // results in missing module name in /proc/misc
> #endif
> minor: MINOR,
> fops: &my_fops
> };
>
> int __init my_init(void)
> {
> misc_register(&my_miscdev);
> return 0;
> }
>
>
> void __exit my_exit(void)
> {
> misc_deregister(&my_miscdev);
> }
>
> module_init(my_init);
> module_exit(my_exit);
>
>
>
>
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
More information about the Linuxppc-embedded
mailing list