- Posts: 13
- Thank you received: 0
A simple question: How to use EXPORT_SYMBOL()
1 year 6 months ago #326509
by RushA
A simple question: How to use EXPORT_SYMBOL() was created by RushA
hi,
I have a question in using linuxcnc 2.9.
I want to call the function defined in the other module. In module A, I export a function using EXPROT_SYMBOL(). In module B, I use "extern" to declare the function and call it. However, it always tells me "undefined symbol". How to solve this problem?
I have a question in using linuxcnc 2.9.
I want to call the function defined in the other module. In module A, I export a function using EXPROT_SYMBOL(). In module B, I use "extern" to declare the function and call it. However, it always tells me "undefined symbol". How to solve this problem?
Please Log in to join the conversation.
1 year 6 months ago #326576
by andypugh
Replied by andypugh on topic A simple question: How to use EXPORT_SYMBOL()
Presumably this is in C?
You may need ti #include A.h in B.c
You may need ti #include A.h in B.c
Please Log in to join the conversation.
1 year 6 months ago #326782
by RushA
Replied by RushA on topic A simple question: How to use EXPORT_SYMBOL()
hi, thanks!
yes, it's C. I did include A.h in B.c, but it doesn't work.
yes, it's C. I did include A.h in B.c, but it doesn't work.
Please Log in to join the conversation.
1 year 6 months ago #326824
by andypugh
Replied by andypugh on topic A simple question: How to use EXPORT_SYMBOL()
Maybe both modules also need to include <linux/module.h> ?
lkw.readthedocs.io/en/latest/doc/04_exporting_symbols.html
lkw.readthedocs.io/en/latest/doc/04_exporting_symbols.html
Please Log in to join the conversation.
1 year 6 months ago #326864
by RushA
Replied by RushA on topic A simple question: How to use EXPORT_SYMBOL()
hi,thanks!
It doesn't work too. However, I find something in rtapi.h file.
I think it is not like the linux kernel modules.
#if !defined(__KERNEL__)
#define MODULE_INFO1(t, a, c) __attribute__((section(".modinfo"))) \
t rtapi_info_##a = c; EXPORT_SYMBOL(rtapi_info_##a);
#define MODULE_INFO2x(t, a, b, c) MODULE_INFO2(t,a,b,c)
#define MODULE_INFO2(t, a, b, c) __attribute__((section(".modinfo"))) \
t rtapi_info_##a##_##b = c; EXPORT_SYMBOL(rtapi_info_##a##_##b);
#define MODULE_PARM(v,t) MODULE_INFO2(const char*, type, v, t) MODULE_INFO2(void*, address, v, &v)
#define MODULE_PARM_DESC(v,t) MODULE_INFO2(const char*, description, v, t)
#define MODULE_LICENSE(s) MODULE_INFO1(const char*, license, s)
#define MODULE_AUTHOR(s) MODULE_INFO1(const char*, author, s)
#define MODULE_DESCRIPTION(s) MODULE_INFO1(const char*, description, s)
#define MODULE_SUPPORTED_DEVICE(s) MODULE_INFO1(const char*, supported_device, s)
#define MODULE_DEVICE_TABLE(x,y) MODULE_INFO2(struct rtapi_pci_device_id*, device_table, x, y)
#define MODULE_INFO(x,y) MODULE_INFO2x(char*, x, __LINE__, y)
#define EXPORT_SYMBOL(x) __attribute__((section(".rtapi_export"))) \
char rtapi_exported_##x = #x;
#define EXPORT_SYMBOL_GPL(x) __attribute__((section(".rtapi_export"))) \
char rtapi_exported_##x = #x;
It doesn't work too. However, I find something in rtapi.h file.
I think it is not like the linux kernel modules.
#if !defined(__KERNEL__)
#define MODULE_INFO1(t, a, c) __attribute__((section(".modinfo"))) \
t rtapi_info_##a = c; EXPORT_SYMBOL(rtapi_info_##a);
#define MODULE_INFO2x(t, a, b, c) MODULE_INFO2(t,a,b,c)
#define MODULE_INFO2(t, a, b, c) __attribute__((section(".modinfo"))) \
t rtapi_info_##a##_##b = c; EXPORT_SYMBOL(rtapi_info_##a##_##b);
#define MODULE_PARM(v,t) MODULE_INFO2(const char*, type, v, t) MODULE_INFO2(void*, address, v, &v)
#define MODULE_PARM_DESC(v,t) MODULE_INFO2(const char*, description, v, t)
#define MODULE_LICENSE(s) MODULE_INFO1(const char*, license, s)
#define MODULE_AUTHOR(s) MODULE_INFO1(const char*, author, s)
#define MODULE_DESCRIPTION(s) MODULE_INFO1(const char*, description, s)
#define MODULE_SUPPORTED_DEVICE(s) MODULE_INFO1(const char*, supported_device, s)
#define MODULE_DEVICE_TABLE(x,y) MODULE_INFO2(struct rtapi_pci_device_id*, device_table, x, y)
#define MODULE_INFO(x,y) MODULE_INFO2x(char*, x, __LINE__, y)
#define EXPORT_SYMBOL(x) __attribute__((section(".rtapi_export"))) \
char rtapi_exported_##x = #x;
#define EXPORT_SYMBOL_GPL(x) __attribute__((section(".rtapi_export"))) \
char rtapi_exported_##x = #x;
Please Log in to join the conversation.
1 year 6 months ago #326896
by andypugh
Replied by andypugh on topic A simple question: How to use EXPORT_SYMBOL()
Are you #including rtapi.h ?
Thinking about it, you can probably use the buuilt-in EXPORT_SYMBOL in kernel modules (ie, if using RTAI). But in uspace this may be re-defined to be something else. (as suggested by the code you posted)
Thinking about it, you can probably use the buuilt-in EXPORT_SYMBOL in kernel modules (ie, if using RTAI). But in uspace this may be re-defined to be something else. (as suggested by the code you posted)
Please Log in to join the conversation.
Time to create page: 0.086 seconds
