All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Linking shared library which relies on bootstrap.o fails
@ 2017-11-28 16:18 Giulio Moro
  2017-11-28 16:27 ` Philippe Gerum
  2017-11-28 23:24 ` [Xenomai] Library cannot be dlopen()ed Giulio Moro
  0 siblings, 2 replies; 6+ messages in thread
From: Giulio Moro @ 2017-11-28 16:18 UTC (permalink / raw)
  To: xenomai

armv7 (BeagleBone Black), Xenomai 3.0.5.

When linking a shared library with something like 
  gcc `/usr/xenomai/bin/xeno-config --skin=alchemy --ldflags` -rdynamic -shared -o libmylib.so 

I get 

/usr/bin/ld: /usr/xenomai/lib/xenomai/bootstrap.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/xenomai/lib/xenomai/bootstrap.o: error adding symbols: Bad value

I understand this can be fixed by compiling the Xenomai library (or at least boostrap.o) with -fPIC. 

Should this not be made the default setting?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] Linking shared library which relies on bootstrap.o fails
  2017-11-28 16:18 [Xenomai] Linking shared library which relies on bootstrap.o fails Giulio Moro
@ 2017-11-28 16:27 ` Philippe Gerum
  2017-11-28 23:24 ` [Xenomai] Library cannot be dlopen()ed Giulio Moro
  1 sibling, 0 replies; 6+ messages in thread
From: Philippe Gerum @ 2017-11-28 16:27 UTC (permalink / raw)
  To: Giulio Moro, xenomai

On 11/28/2017 05:18 PM, Giulio Moro wrote:
> armv7 (BeagleBone Black), Xenomai 3.0.5.
> 
> When linking a shared library with something like 
>   gcc `/usr/xenomai/bin/xeno-config --skin=alchemy --ldflags` -rdynamic -shared -o libmylib.so 
> 
> I get 
> 
> /usr/bin/ld: /usr/xenomai/lib/xenomai/bootstrap.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
> /usr/xenomai/lib/xenomai/bootstrap.o: error adding symbols: Bad value
> 
> I understand this can be fixed by compiling the Xenomai library (or at least boostrap.o) with -fPIC. 
> 

No, please see the documentation about --auto-init, --auto-init-solib:
https://xenomai.org/documentation/xenomai-3/html/man1/xeno-config/index.html

> Should this not be made the default setting?

No, we need a non-PIC version for pure execs too. This is why we have
two builds of bootstrap.o - PIC and non-PIC, selected by the proper
xeno-config switch, depending on the link target.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Xenomai] Library cannot be dlopen()ed
  2017-11-28 16:18 [Xenomai] Linking shared library which relies on bootstrap.o fails Giulio Moro
  2017-11-28 16:27 ` Philippe Gerum
@ 2017-11-28 23:24 ` Giulio Moro
  2017-11-29  9:08   ` Philippe Gerum
  2017-12-11 14:03   ` Henning Schild
  1 sibling, 2 replies; 6+ messages in thread
From: Giulio Moro @ 2017-11-28 23:24 UTC (permalink / raw)
  To: xenomai

Again, armv7 BeagleBone Black, Xenomai 3.0.5

My main executable uses the posix API, hence ldd tells me :
	libcobalt.so.2 => /usr/xenomai/lib/libcobalt.so.2 (0xb6ed3000)
	libmodechk.so.0 => /usr/xenomai/lib/libmodechk.so.0 (0xb6f39000)

I am trying to dlopen() a library which uses the native API (alchemy+transition kit):
	libtrank.so.0 => /usr/xenomai/lib/libtrank.so.0 (0xb6e71000)
	libalchemy.so.0 => /usr/xenomai/lib/libalchemy.so.0 (0xb6e58000)
	libcopperplate.so.0 => /usr/xenomai/lib/libcopperplate.so.0 (0xb6e3d000)
	libcobalt.so.2 => /usr/xenomai/lib/libcobalt.so.2 (0xb6e18000)
	libmodechk.so.0 => /usr/xenomai/lib/libmodechk.so.0 (0xb6e07000)

the call to dlopen() fails with the following message:
libtrank.so.0: shared object cannot be dlopen()ed

grepping the configured Xenomai source for "nodlopen" shows that all (or most) of the libraries are compiled with -Wl,nodlopen, which is what is preventing dlopen() from working.

I have two questions:
- is it possible to dynamically load a library which uses the alchemy API from a program that uses the cobalt API?
- is it at all possible to dynamically load a library that uses xenomai in a program that was not linked against xenomai?

Thanks,
Giulio


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] Library cannot be dlopen()ed
  2017-11-28 23:24 ` [Xenomai] Library cannot be dlopen()ed Giulio Moro
@ 2017-11-29  9:08   ` Philippe Gerum
  2017-11-29 16:52     ` Giulio Moro
  2017-12-11 14:03   ` Henning Schild
  1 sibling, 1 reply; 6+ messages in thread
From: Philippe Gerum @ 2017-11-29  9:08 UTC (permalink / raw)
  To: Giulio Moro, xenomai

On 11/29/2017 12:24 AM, Giulio Moro wrote:
> Again, armv7 BeagleBone Black, Xenomai 3.0.5
> 
> My main executable uses the posix API, hence ldd tells me :
> 	libcobalt.so.2 => /usr/xenomai/lib/libcobalt.so.2 (0xb6ed3000)
> 	libmodechk.so.0 => /usr/xenomai/lib/libmodechk.so.0 (0xb6f39000)
> 
> I am trying to dlopen() a library which uses the native API (alchemy+transition kit):
> 	libtrank.so.0 => /usr/xenomai/lib/libtrank.so.0 (0xb6e71000)
> 	libalchemy.so.0 => /usr/xenomai/lib/libalchemy.so.0 (0xb6e58000)
> 	libcopperplate.so.0 => /usr/xenomai/lib/libcopperplate.so.0 (0xb6e3d000)
> 	libcobalt.so.2 => /usr/xenomai/lib/libcobalt.so.2 (0xb6e18000)
> 	libmodechk.so.0 => /usr/xenomai/lib/libmodechk.so.0 (0xb6e07000)
> 
> the call to dlopen() fails with the following message:
> libtrank.so.0: shared object cannot be dlopen()ed
> 
> grepping the configured Xenomai source for "nodlopen" shows that all (or most) of the libraries are compiled with -Wl,nodlopen, which is what is preventing dlopen() from working.
> 
> I have two questions:
> - is it possible to dynamically load a library which uses the alchemy API from a program that uses the cobalt API?
> - is it at all possible to dynamically load a library that uses xenomai in a program that was not linked against xenomai?
> 
> Thanks,
> Giulio
> 
> _______________________________________________
> Xenomai mailing list
> Xenomai@xenomai.org
> https://xenomai.org/mailman/listinfo/xenomai
> 

As mentioned in the documentation, --enable-dlopen-libs is needed when
configuring:

https://xenomai.org/installing-xenomai-3-x/#Generic_configuration_options_both_cores

-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] Library cannot be dlopen()ed
  2017-11-29  9:08   ` Philippe Gerum
@ 2017-11-29 16:52     ` Giulio Moro
  0 siblings, 0 replies; 6+ messages in thread
From: Giulio Moro @ 2017-11-29 16:52 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

> From: Philippe Gerum <rpm@xenomai.org>
> As mentioned in the documentation, --enable-dlopen-libs is needed when configuring

Brilliant, thanks. The docs mentions

> Enabling dynamic loading introduces some overhead in TLS accesses when enabled (see --enable-tls), which might be noticeable depending on the architecture.

Can you make an example of what operations incur overhead?

Thanks,
Giulio

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] Library cannot be dlopen()ed
  2017-11-28 23:24 ` [Xenomai] Library cannot be dlopen()ed Giulio Moro
  2017-11-29  9:08   ` Philippe Gerum
@ 2017-12-11 14:03   ` Henning Schild
  1 sibling, 0 replies; 6+ messages in thread
From: Henning Schild @ 2017-12-11 14:03 UTC (permalink / raw)
  To: Giulio Moro; +Cc: xenomai

Am Tue, 28 Nov 2017 23:24:40 +0000
schrieb Giulio Moro <g.moro@qmul.ac.uk>:

> Again, armv7 BeagleBone Black, Xenomai 3.0.5
> 
> My main executable uses the posix API, hence ldd tells me :
> 	libcobalt.so.2 => /usr/xenomai/lib/libcobalt.so.2 (0xb6ed3000)
> 	libmodechk.so.0 => /usr/xenomai/lib/libmodechk.so.0
> (0xb6f39000)
> 
> I am trying to dlopen() a library which uses the native API
> (alchemy+transition kit): libtrank.so.0
> => /usr/xenomai/lib/libtrank.so.0 (0xb6e71000) libalchemy.so.0
> => /usr/xenomai/lib/libalchemy.so.0 (0xb6e58000) libcopperplate.so.0
> => /usr/xenomai/lib/libcopperplate.so.0 (0xb6e3d000) libcobalt.so.2
> => /usr/xenomai/lib/libcobalt.so.2 (0xb6e18000) libmodechk.so.0
> => /usr/xenomai/lib/libmodechk.so.0 (0xb6e07000)
> 
> the call to dlopen() fails with the following message:
> libtrank.so.0: shared object cannot be dlopen()ed
> 
> grepping the configured Xenomai source for "nodlopen" shows that all
> (or most) of the libraries are compiled with -Wl,nodlopen, which is
> what is preventing dlopen() from working.
> 
> I have two questions:
> - is it possible to dynamically load a library which uses the alchemy
> API from a program that uses the cobalt API?
> - is it at all possible to dynamically load a library that uses
> xenomai in a program that was not linked against xenomai?

Yes and yes. But i guess you have figured that out already.

Henning

> Thanks,
> Giulio
> 
> _______________________________________________
> Xenomai mailing list
> Xenomai@xenomai.org
> https://xenomai.org/mailman/listinfo/xenomai


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-11 14:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 16:18 [Xenomai] Linking shared library which relies on bootstrap.o fails Giulio Moro
2017-11-28 16:27 ` Philippe Gerum
2017-11-28 23:24 ` [Xenomai] Library cannot be dlopen()ed Giulio Moro
2017-11-29  9:08   ` Philippe Gerum
2017-11-29 16:52     ` Giulio Moro
2017-12-11 14:03   ` Henning Schild

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.