c - multiple definiton of function-error in kernel-file -


hey guys. i'm trying port tool digsig centos-kernel seems lack few important crypto-functions digsig. port newer /linux/crypto.h has functionality need plus added little code:

void kzfree(const void *p) {     size_t ks;     void *mem = (void *)p;      if (unlikely(zonp(mem)))              return;     ks = ksize(mem);     memset(mem, 0, ks);     kfree(mem); 

}

because kernel i'm working on not have kzfree yet. now, when try compile digsig, output:

/home/chris/dstest/dsi_sysfs.o: in function `kzfree': /usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: multiple definition of `kzfree' /home/chris/dstest/digsig.o:/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: first defined here /home/chris/dstest/digsig_cache.o: in function `kzfree': /usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: multiple definition of `kzfree' /home/chris/dstest/digsig.o:/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: first defined here /home/chris/dstest/digsig_revocation.o: in function `kzfree': /usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: multiple definition of `kzfree' /home/chris/dstest/digsig.o:/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: first defined here /home/chris/dstest/dsi_sig_verify.o: in function `kzfree': /usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: multiple definition of `kzfree' /home/chris/dstest/digsig.o:/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h:114: first defined here 

of course, covered #ifndef-guards, cannot understand why defining function multiple times... ideas?

your include file gets included in multiple places. not compile time error. rather linked time error. each of file got compiled , produced following .o files

/home/chris/dstest/dsi_sysfs.o /home/chris/dstest/digsig_cache.o /home/chris/dstest/digsig_revocation.o /home/chris/dstest/dsi_sig_verify.o 

now while linking them finds multiple definition of kzfreez, 1 each in above .o files because corresponding c files included

/usr/src/kernels/2.6.18-194.32.1.el5-i686/include/linux/crypto.h 

you have ifdef guarded file, prevents inclusion of .h file in same c file (translation units) not across different c files.

you should write function in c file , add in in make files, gets compiled separately , linked. , add declaration in crypto.h . (for testing can add definition in crypto.c , declaration in crypto.h).


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -