dlopen failing when using shared library on xenomai 3.0.4
Hello all,
I'm trying to port machinekit (machinekit.io) to xenomai 3.0.4 which support only xenomai 2.6.4 for the moment.
This software is design this way :
A : main executable
B : shared library abstracting thread API, with one library for posix, for xenomai, ...
The xenomai B library is linked against alchemy, copperplate, ... (xeno-config --ldflags --auto-init-solib --skin=alchemy)
The program works in a way that, at start time, it load with dlopen the configured API (B).
My problem is that dlopen(with RTLD_GLOBAL|RTLD_NOW) fail with the error : "/usr/lib/libcopperplate.so.0: undefined symbol: main"
Here is the simplified test case to reproduce the problem :
main.c:
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main(int argc, char *const argv[])
{
void *handle;
handle = dlopen("./ulapi-xenomai.so", RTLD_GLOBAL|RTLD_NOW);
if (!handle) {
fprintf(stderr, "%s\n", dlerror());
exit(EXIT_FAILURE);
}
dlclose(handle);
exit(EXIT_SUCCESS);
}gcc main.c -o testcase -ldl
gcc -Wl,-soname,ulapi-xenomai.so -shared -o ulapi-xenomai.so xeno-config --ldflags --auto-init-solib --skin=alchemy
run testcase
I am missing something or is there a solution that doesn't imply to use RTLD_LAZY ?
my xeno-config --info
Xenomai version: Xenomai/cobalt v3.0.4
Linux beaglebone 4.4.62-ti-xenomai-r105 #1 SMP Wed May 24 00:09:09 UTC 2017 armv7l GNU/Linux
Kernel parameters: console=ttyO0,115200n8 capemgr.disable_partno=BB-BONELT-HDMI bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet I-pipe release #7 detected
Cobalt core 3.0.4 detected
Compiler: gcc version 4.9.2 (Debian 4.9.2-10)
Build args: --prefix=/usr --includedir=/usr/include/xenomai --mandir=/usr/share/man --with-testdir=/usr/lib/xenomai/testsuite --enable-dlopen-libs --enable-smp --build arm-linux-gnueabihf build_alias=arm-linux-gnueabihf
Regards,
Fyleo
Quoted 12 lines · Fyleo
Hello all,
I'm trying to port machinekit (machinekit.io) to xenomai 3.0.4 which support only xenomai 2.6.4 for the moment.
This software is design this way :
A : main executable
B : shared library abstracting thread API, with one library for posix, for xenomai, ...
Quoted 9 lines
The xenomai B library is linked against alchemy, copperplate, ... (xeno-config --ldflags --auto-init-solib --skin=alchemy)
The program works in a way that, at start time, it load with dlopen the configured API (B).
My problem is that
dlopen(with RTLD_GLOBAL|RTLD_NOW)fail with the error : "/usr/lib/libcopperplate.so.0: undefined symbol: main"
Could you pick the change below and retry? Feedback welcome.
http://git.xenomai.org/xenomai-3.git/commit/?id=48b2e57e29ca1c33eba14abb4b5eaa15431130fa
Signature · 1 line
Philippe.
Quoted 19 lines · Philippe Gerum
Quoted 18 lines · Fyleo
Hello all,
I'm trying to port machinekit (machinekit.io) to xenomai 3.0.4 which support only xenomai 2.6.4 for the moment.
This software is design this way :
A : main executable
B : shared library abstracting thread API, with one library for posix, for xenomai, ...
The xenomai B library is linked against alchemy, copperplate, ... (xeno-config --ldflags --auto-init-solib --skin=alchemy)
The program works in a way that, at start time, it load with dlopen the configured API (B).
Quoted 7 lines
Quoted 3 lines
My problem is that
dlopen(with RTLD_GLOBAL|RTLD_NOW)fail with the error : "/usr/lib/libcopperplate.so.0: undefined symbol: main"Could you pick the change below and retry? Feedback welcome.
http://git.xenomai.org/xenomai-3.git/commit/?id=48b2e57e29ca1c33eba14abb4b5eaa15431130fa
Hi,
This fix works, thanks.
But will it always work in executable auto init ? The symbol "__real_main" have to be defined in user code if linked with bootstrap.o ?
Fyleo
Quoted 28 lines · Fyleo
Quoted 19 lines · Philippe Gerum
Quoted 18 lines · Fyleo
Hello all,
I'm trying to port machinekit (machinekit.io) to xenomai 3.0.4 which support only xenomai 2.6.4 for the moment.
This software is design this way :
A : main executable
B : shared library abstracting thread API, with one library for posix, for xenomai, ...
The xenomai B library is linked against alchemy, copperplate, ... (xeno-config --ldflags --auto-init-solib --skin=alchemy)
The program works in a way that, at start time, it load with dlopen the configured API (B).
Quoted 8 lines
Quoted 3 lines
My problem is that
dlopen(with RTLD_GLOBAL|RTLD_NOW)fail with the error : "/usr/lib/libcopperplate.so.0: undefined symbol: main"Could you pick the change below and retry? Feedback welcome.
http://git.xenomai.org/xenomai-3.git/commit/?id=48b2e57e29ca1c33eba14abb4b5eaa15431130fa
Quoted 7 lines
Hi,
This fix works, thanks.
But will it always work in executable auto init ? The symbol "
__real_main" have to be defined in user code if linked with bootstrap.o ?
__real_main() stands for the actual main as generated by the linker when the auto-bootstrap feature is in effect (i.e. --wrap=main --dynamic-list=...), and bootstrap.o is glued to executables/DSOs only in such a case. IOW, __real_main() is guaranteed to exist if bootstrap.o is part of the binary image.
So yes, we should be safe. This change has been tested with the alchemy testsuite which is copperplate-based, a C++ application enabling auto-init-solib, and Xenomai's base utility programs enabling the auto-bootstrap, so far so good.
Signature · 1 line
Philippe.
Hi,
Why don't you link the shared lib at compilation ?
Regards,
S.Ancelot
Quoted 64 lines · Fyleo
Hello all,
I'm trying to port machinekit (machinekit.io) to xenomai 3.0.4 which support only xenomai 2.6.4 for the moment.
This software is design this way :
A : main executable
B : shared library abstracting thread API, with one library for posix, for xenomai, ...
The xenomai B library is linked against alchemy, copperplate, ... (xeno-config --ldflags --auto-init-solib --skin=alchemy)
The program works in a way that, at start time, it load with dlopen the configured API (B).
My problem is that
dlopen(with RTLD_GLOBAL|RTLD_NOW)fail with the error : "/usr/lib/libcopperplate.so.0: undefined symbol: main"Here is the simplified test case to reproduce the problem :
main.c:#include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int main(int argc, char *const argv[]) { void *handle; handle = dlopen("./ulapi-xenomai.so", RTLD_GLOBAL|RTLD_NOW); if (!handle) { fprintf(stderr, "%s\n", dlerror()); exit(EXIT_FAILURE); } dlclose(handle); exit(EXIT_SUCCESS); }gcc
main.c-o testcase -ldl
gcc -Wl,-soname,ulapi-xenomai.so -shared -o ulapi-xenomai.soxeno-config --ldflags --auto-init-solib --skin=alchemyrun testcase
I am missing something or is there a solution that doesn't imply to use
RTLD_LAZY?my xeno-config --info
Xenomai version: Xenomai/cobalt v3.0.4
Linux beaglebone 4.4.62-ti-xenomai-r105 #1 SMP Wed May 24 00:09:09 UTC 2017 armv7l GNU/Linux
Kernel parameters: console=ttyO0,115200n8 capemgr.disable_partno=BB-BONELT-HDMI bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet I-pipe release #7 detected
Cobalt core 3.0.4 detected
Compiler: gcc version 4.9.2 (Debian 4.9.2-10)
Build args: --prefix=/usr --includedir=/usr/include/xenomai
--mandir=/usr/share/man --with-testdir=/usr/lib/xenomai/testsuite
--enable-dlopen-libs --enable-smp --build arm-linux-gnueabihf
build_alias=arm-linux-gnueabihfRegards,
Fyleo
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai
Quoted 66 lines · Fyleo
Quoted 64 lines
Hello all,
I'm trying to port machinekit (machinekit.io) to xenomai 3.0.4 which support only xenomai 2.6.4 for the moment.
This software is design this way :
A : main executable
B : shared library abstracting thread API, with one library for posix, for xenomai, ...
The xenomai B library is linked against alchemy, copperplate, ... (xeno-config --ldflags --auto-init-solib --skin=alchemy)
The program works in a way that, at start time, it load with dlopen the configured API (B).
My problem is that
dlopen(with RTLD_GLOBAL|RTLD_NOW)fail with the error : "/usr/lib/libcopperplate.so.0: undefined symbol: main"Here is the simplified test case to reproduce the problem :
main.c:#include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int main(int argc, char *const argv[]) { void *handle; handle = dlopen("./ulapi-xenomai.so", RTLD_GLOBAL|RTLD_NOW); if (!handle) { fprintf(stderr, "%s\n", dlerror()); exit(EXIT_FAILURE); } dlclose(handle); exit(EXIT_SUCCESS); }gcc
main.c-o testcase -ldl
gcc -Wl,-soname,ulapi-xenomai.so -shared -o ulapi-xenomai.soxeno-config --ldflags --auto-init-solib --skin=alchemyrun testcase
I am missing something or is there a solution that doesn't imply to use
RTLD_LAZY?my xeno-config --info
Xenomai version: Xenomai/cobalt v3.0.4
Linux beaglebone 4.4.62-ti-xenomai-r105 #1 SMP Wed May 24 00:09:09 UTC 2017 armv7l GNU/Linux
Kernel parameters: console=ttyO0,115200n8 capemgr.disable_partno=BB-BONELT-HDMI bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet I-pipe release #7 detected
Cobalt core 3.0.4 detected
Compiler: gcc version 4.9.2 (Debian 4.9.2-10)
Build args: --prefix=/usr --includedir=/usr/include/xenomai
--mandir=/usr/share/man --with-testdir=/usr/lib/xenomai/testsuite
--enable-dlopen-libs --enable-smp --build arm-linux-gnueabihf
build_alias=arm-linux-gnueabihfRegards,
Fyleo
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai
Quoted 6 lines · Stéphane Ancelot
Hi,
Why don't you link the shared lib at compilation ?
Regards,
S.Ancelot
Hi,
Because there is multiple ulapi that can be loaded at execution time to switch between posix (non-xenomai) thread, xenomai thread, rtai thread and so on, depending on environnement variable. It is not my program so i want to be less invasive as possible.
Regards,
Fyleo