>>>But during modposting stage, I suspect a CRC check is done, on top of >>>just the "extern" call, but because sys_clock_gettime() is not >>>declared as EXPORT_SYMBOL().....the symbol become not accessible from >>>a module. but if u compile the codes together with the kernel ELF >>>image, compilation and runtime should not have any error. Problem >>>now is modposting check done for a module......correct? In my opinion,i think when u compile a module ,only compile a C file ,not link.like you do gcc -c *.c and make a object file.when you insmod the module ,this moment begins to link and insmod performs like a linker to do some symbol link check CRC etc. 2009/2/26 Peter Teoh <htmldeveloper@xxxxxxxxx>: > feel free to correct me. > > since SYSCALL_DEFINE2() is ultimately defined as (include/linux/syscalls.h): > > #define SYSCALL_DEFINEx(x, name, ...) \ > asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \ > static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ > asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \ > { \ > __SC_TEST##x(__VA_ARGS__); \ > return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \ > } \ > SYSCALL_ALIAS(sys##name, SyS##name); \ > static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)) > > so your sys_clock_gettime() will ultimately be declared as asmlinkage > long sys_clock_gettime(), where asmlinkage will be mapped to something > (irrelevant here) not related to static, which means that the symbol > can always be accessed globally - just by issuing extern from the > demand side. Correct? > > the error "symbol not found" must have occurred before this header > file is included. perhaps after u included this header, then extern, > then the symbol become accessible? I attempted, results as follows. > > C-wise, syntactically / semantically correct - compilation no errors: > > make -C /lib/modules/2.6.29-rc5/build > M=/sda1/download/linux-2.6/for-linus/drivers/mymodule modules > make[1]: Entering directory `/sda1/download/linux-2.6/for-linus' > CC [M] /sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.o > /sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.c: In > function ‘init_hello_4’: > /sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.c:20: > warning: ‘which_clock’ is used uninitialized in this function > /sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.c:20: > warning: ‘tp’ is used uninitialized in this function > Building modules, stage 2. > MODPOST 1 modules > WARNING: "sys_clock_gettime" > [/sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.ko] > undefined! > CC /sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.mod.o > LD [M] /sda1/download/linux-2.6/for-linus/drivers/mymodule/peter.ko > make[1]: Leaving directory `/sda1/download/linux-2.6/for-linus' > > But during modposting stage, I suspect a CRC check is done, on top of > just the "extern" call, but because sys_clock_gettime() is not > declared as EXPORT_SYMBOL().....the symbol become not accessible from > a module. but if u compile the codes together with the kernel ELF > image, compilation and runtime should not have any error. Problem > now is modposting check done for a module......correct? > > On Wed, Feb 25, 2009 at 6:08 PM, Ole Loots <ole@xxxxxxxxxxxxx> wrote: >> Hello, >> >> I want to call the kernel function sys_clock_gettime, but when I just try to >> call it, the linker complains about the unknown symbol/function >> sys_clock_gettime, so i have hard coded a function pointer in my module...: >> >> long (*p_sys_clock_gettime)(clockid_t, struct timespec *tp) = 0xc004373c; >> >> That works fine for my system, but I know thats not the way to do it. How is >> it done properly? >> >> Regards, >> Ole >> >> >> -- >> To unsubscribe from this list: send an email with >> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx >> Please read the FAQ at http://kernelnewbies.org/FAQ >> >> > > > > -- > Regards, > Peter Teoh > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx > Please read the FAQ at http://kernelnewbies.org/FAQ > > -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ