Re: Re: problem in adding 2 modules to kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

Hello Bhavpreet,
          Got it working with warning. Output at my machine is

[parag@router1 root]# gcc -O2 -DMODULE -D__KERNEL__  -isystem /lib/modules/`uname -r`/build/include  -c -o parag.o parag.c
parag.c: In function `__init_module_inline':
parag.c:41: warning: return from incompatible pointer type

I am still unclear about how can i add this code to linux kernel?
          anybody can help me to include my kernel modules to linux kernel.
regards,
Parag.



On Sat, 11 Dec 2004 Bhavpreet Singh wrote :
>bunty wrote:
>
>>  Hello Bhavpreet,
>>                Is that independent module program? Have you written it for separate execution? I tried it on my linux RH9 with same makefile and i got following errors.
>>[parag@router1 parag]# make
>>make: Circular parag <- parag dependency dropped.
>>gcc -O2 -DMODULE -D__KERNEL__  -isystem /lib/modules/`uname -r`/build/include      -o .c
>>gcc: no input files
>>make: *** [.c] Error 1
>>
>>If this Makefile can be integrated in linux kernel then where can i include it in kernel? I want my module programs to be compiled with other files in kernel compilation.
>>
>>regards,
>>Parag.
>>
>>
>>On Fri, 10 Dec 2004 Bhavpreet Singh wrote :
>> >bunty wrote:
>> >
>> >
>> >Hello,
>> >    I have written 2 modules that i want to be loaded each time kernel
>> >has been loaded. I add them in kernel directory of kernel source but i
>> >am getting following error
>> >deny2.o(.text+0x50): In function `init_module':
>> >: multiple definition of `init_module'
>> >deny1.o(.text+0x190): first defined here
>> >ld: Warning: size of symbol `init_module' changed from 110 to 57 in
>> >deny2.o
>> >deny2.o(.text+0x90): In function `cleanup_module':
>> >: multiple definition of `cleanup_module'
>> >deny1.o(.text+0x200): first defined here
>> >ld: Warning: size of symbol `cleanup_module' changed from 29 to 17 in
>> >deny2.o
>> >make[2]: *** [kernel.o] Error 1
>> >make[2]: Leaving directory `/usr/src/linux-2.4.24-module/kernel'
>> >make[1]: *** [first_rule] Error 2
>> >make[1]: Leaving directory `/usr/src/linux-2.4.24-module/kernel'
>> >make: *** [_dir_kernel] Error 2
>> >Both kernel modules have following similar calls code
>> >static void __init init(void)
>> >          {
>> >              nfho.hook    = hook_func;
>> >              nfho.hooknum  = NF_IP_POST_ROUTING;
>> >              nfho.pf      = PF_INET;
>> >              nfho.priority = NF_IP_PRI_FIRST;
>> >              nf_register_hook(&nfho);
>> >  >          }
>> >static void __exit fini(void)
>> >          {
>> >              nf_unregister_hook(&nfho);
>> >          }
>> >module_init(init);
>> >module_exit(fini);
>> >MODULE_LICENSE("GPL");
>> >how to solve this error?
>> >regards,
>> >parag.
>> >
>> >parag,
>> >Things work fine for me.
>> >I did the following:
>> ><++>parag.c<++>
>> >#include <linux/module.h>
>> >#include <linux/kernel.h>
>> >#include <linux/netdevice.h>
>> >#include <linux/netfilter.h>
>> >#include <linux/netfilter_ipv4.h>
>> >#include <linux/time.h>
>> >#include <linux/slab.h>
>> >#include <linux/sched.h>
>> >#include <net/sock.h>
>> >static struct nf_hook_ops nfho;
>> >unsigned int hook_func(unsigned int hooknum,
>> >                      struct sk_buff **skb,
>> >                      const struct net_device *in,
>> >                      const struct net_device *out,
>> >                      int (*okfn)(struct sk_buff *))
>> >{
>> >  return NF_ACCEPT;
>> >}
>> >static void __init init(void)
>> >{
>> >  nfho.hook    = hook_func;
>> >  nfho.hooknum  = NF_IP_POST_ROUTING;
>> >  nfho.pf      = PF_INET;
>> >  nfho.priority = NF_IP_PRI_FIRST;
>> >  nf_register_hook(&nfho);
>> >}
>> >static void __exit fini(void)
>> >{
>> >  nf_unregister_hook(&nfho);
>> >}
>> >module_init(init);
>> >module_exit(fini);
>> >MODULE_LICENSE("GPL");
>> ><--> parag.c <-->
>> ><++> Makefile <++>
>> >TARGET  := parag
>> >WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>> >WARN    :=
>> >INCLUDE := -isystem /lib/modules/`uname -r`/build/include
>> >CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
>> >CC      := gcc
>> >all: ${TARGET}.o
>> >${TARGET}.o: ${TARGET}.c
>> >.PHONY: clean
>> >clean:
>> >        rm -rf ${TARGET}.o
>> ><--> Makefile <-->
>> >Cheers!
>> >      /|\ /\ ><
>> >TheMatrixTen
>> >--
>> >Kernelnewbies: Help each other learn about the Linux kernel.
>> >Archive:      http://mail.nl.linux.org/kernelnewbies/
>> >FAQ:          http://kernelnewbies.org/faq/
>> >
>> >
>>
>>
>>
>><http://clients.rediff.com/signature/track_sig.asp>
>
>
>There is something wrong with the make file you are using, its running fine on RH9
>also with:  2.4.20-8
>
>-------------------snip---------------------
>$ cat Makefile
>TARGET  := parag
>WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
>WARN    :=
>INCLUDE := -isystem /lib/modules/`uname -r`/build/include
>
>CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
>CC      := gcc
>
>all: ${TARGET}.o
>
>${TARGET}.o: ${TARGET}.c
>
>.PHONY: clean
>
>clean:
>        rm -rf ${TARGET}.o
>$ make
>gcc -O2 -DMODULE -D__KERNEL__  -isystem /lib/modules/`uname -r`/build/include  -c -o parag.o parag.c
>parag.c: In function `__init_module_inline':
>parag.c:41: warning: return from incompatible pointer type
>$ ls
>Makefile  parag.c  parag.o
>$
>
>------------------snip-----------------
>
>you might try to run :
>gcc -O2 -DMODULE -D__KERNEL__  -isystem /lib/modules/`uname -r`/build/include  -c -o parag.o parag.c
>
>
>
>      /|\ /\ ><
>TheMatrixTen
>
>
>
>--
>Kernelnewbies: Help each other learn about the Linux kernel.
>Archive:      http://mail.nl.linux.org/kernelnewbies/
>FAQ:          http://kernelnewbies.org/faq/
>




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux