[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: making a static binary out a dynamic
- To: "Mevorach, Assaf" <assaf.mevorach(at-nospam)intel.com>
- Subject: RE: making a static binary out a dynamic
- From: guy keren <choo(at-nospam)actcom.co.il>
- Date: Wed, 3 Jan 2001 12:49:45 +0200 (EET)
- cc: "'erez(at-nospam)savan.com'" <erez(at-nospam)savan.com>, ILUG <linux-il(at-nospam)cs.huji.ac.il>
- In-Reply-To: <71984F8FB76AD211AC3E00A0C9C578C702B98324@hasmsx32.iil.intel.com>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
On Wed, 3 Jan 2001, Mevorach, Assaf wrote:
> you can do it, but it will not solve your problem.
> linking libc statically with executable doesn't shrink it, it is still the
> executable and libc together.
did you realy _try_ this, or you're only guessing? when the linker links
a library to an executeable, it only takes the parts of the library that
are recursively used by the binary. it does not rull in the complete
library into the resulting static binary. libc would add about 800KB (or
even less) to a normal application - that's the figure i believe i saw.
> another resolution might be to see what calls to libc youare using and to
> put their implementation (as source) in your own libc
> (create a subset oflibc -> mylibc)
this is exactly what the linker does - only it does so effotrlessly.
> second resolution that now came up to me : try to strip it. (use the 'strip;
> tool on the exe and on libc)
strip is a good idea. but you need to add a flag to actually strip ALL
redundant information. by defaut;t 'strip' only stripts _some_ of the
information. looks like '-s' is the flag for gnu strip.
as for the original problem - that of having no source file - you'll have
to go to some odd paths, of extracting only the needed object files from
the static libc (using 'ar'), then using them to create a new dynamic libc
(using 'gcc -shared'), and finally adding any missing symbols (i checked
this with LS, and the static libc is missing the symbol GLIBC_2.1, and
another similar symbol. you'll need to create them manualy by adding your
own object file that defines them, into your newly created shared
library).
in other words - you need to be pretty familiar with how the gnu compiler,
linker and dynamic loader exactly work.
maybe someone has a better way (e.g. search on ther ineternet for that -
maybe someone did this before).
--
guy
"For world domination - press 1,
or dial 0, and please hold, for the creator." -- nob o. dy
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il