This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Is it possible to "partially" link static libraries like this
- From: Paul Fredrickson <qmoto at dsl-only dot net>
- To: binutils at sources dot redhat dot com
- Date: Sun, 16 May 2004 15:36:43 -0700
- Subject: Is it possible to "partially" link static libraries like this
Hi list,
I work for a company that is very zealous about guarding its IP, but is also
increasing its use of third party vendors for its work. We routinely deliver
a static library containing much of our proprietary code to the vendors, who
then build drivers from it. The concern came up recently that the static
library exports everything, not just the limited number functions the vendors
need, and that makes the paranoid even more nervous. So it became my job to
see if we could fix it.
I realize the best solution would be to deliver a dynamically linked library,
with all the unnecessary symbols stripped, and this is what we're planning to
do for the next generation of the product.
Is there some way to accomplish something like this for our current delivery?
I'm not completely familiar with all the possible options to all the tools
available, but I can't seem to construct a solution directly looking at the
available documentation for ld, objcopy, etc. I was hoping something like
this would be possible:
I have the interface functions defined in one set of files:
interface.c (InterfaceFn1(), InterfaceFn2(), ... )
I have all the proprietary code in a set of implementation files:
impl1.c (ImplFn1())
impl2.c (ImplFn2())
etc.
I compile everything to create a list of object files. interface.o has
undefined references to ImplFn1 and ImplFn2. If I simply created the static
library at this point, all the symbols would be global and none of them would
be resolved (the situation I'm faced with today). On the other hand, if I
created a libtemp.a from all the impl object files, could I use that to
create my library using just interface.o, but with as many references as
possible resolved from libtemp.a? The ImplFns could be stripped, leaving
only the InterfaceFn's and undefined references to libc, etc. Does that
explain what I'm trying to do at least? It seems like the new static library
would be "partially linked", but I hestitate to use that term because I'm not
positive it means exactly what the docs mean by "partially linked objects".
If it is, it would be nice to have that confirmed by an expert.
If this list is meant more for tool development rather than discussing unusual
usage scenarios, I apologize and would appreciate pointers to a more
appropriate place to ask.
Thanks!
qmoto