I modified the kernel source code r8169.c
and calculating the timestamp
as below:
s64 a;
EXPORT_SYMBOL(a);
a = time();
I did not add the original timestamp function call
I am using the variable a in another source file in kernel: ip_input.c
extern s64 a;
s64 b,c;
b= time();
c = b-a;
I receive this error:
ERROR: undefined reference to a
How to solve it?
From the incomplete source code, I guess that
s64 a;
EXPORT_SYMBOL(a);
a = time();
is inside a function and therefore, a
cannot be exported, because it is local to that function.
To use a
outside of this module, you must define it with file scope, eg
s64 a;
EXPORT_SYMBOL(a);
void some_function()
{
a = time();
}
This allows the symbol for a
to be exported and then used in another module.
r8169.c is a module, whereas ip_input.c is in the main kernel. The main kernel cannot import symbols from a module. The fix for this is to declare your variable within ip_input.c, and import it from r8169.c. You also have to use file scope as Olaf mentioned.
ip_input.c:
s64 a, b, c;
EXPORT_SYMBOL(a);
void someFunc() {
b=time();
c=b-a;
}
r8169.c:
extern s64 a;
void someFunc() {
a=time();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.