static + dynamic linking problem

Joel Sherrill joel at rtems.org
Fri May 12 18:46:34 UTC 2017


On May 12, 2017 1:41 PM, "Mathew Benson" <mathew.benson at gmail.com> wrote:

I have an application using the RTL dynamic loader.  The loader seems to
work just fine, but two of the dynamic libraries that I'm loading require
math functions in libm.a.  Correct me if I'm wrong, but I can't link those
into the dynamic libraries without symbols colliding.  However, if I put
the -lm in the main executable, the symbols get stripped out even though I
use the "-Wl,--export-dynamic" switch.  If I use a function in the main
executable, that function is exported correctly.  But all unused functions
get stripped out.  It would appear the --export-dynamic only applies to the
.o's and not to any .a's.

I think there are multiple ways to solve this, but I haven't found a clean
solution yet.  One working, but ugly solution is to use "ar x libm.a" to
extract the .o's, then link the .o's with mine.  That combined with the
--export-dynamic exports all the symbols.

I'm thinking this can probably be solved with a toolchain switch.  Is there
any way I can tell the linker to also export all the symbols from the .a's
linked in?  Can I specify specific symbols to export?


There is a --whole-archive option to let which might be of use. But I would
tend to try --U XXX which says XXX is undefined and to include it. I don't
know how that interacts with per method section linking but I think it
would work.

--joel


_______________________________________________
users mailing list
users at rtems.org
http://lists.rtems.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20170512/c386392d/attachment-0002.html>


More information about the users mailing list