[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: making a static binary out a dynamic
- To: "'guy keren'" <choo(at-nospam)actcom.co.il>, "Mevorach, Assaf" <assaf.mevorach(at-nospam)intel.com>
- Subject: RE: making a static binary out a dynamic
- From: "Mevorach, Assaf" <assaf.mevorach(at-nospam)intel.com>
- Date: Wed, 3 Jan 2001 03:27:53 -0800
- Cc: "'erez(at-nospam)savan.com'" <erez(at-nospam)savan.com>, ILUG <linux-il(at-nospam)cs.huji.ac.il>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
> -----Original Message-----
> From: guy keren [mailto:choo@actcom.co.il]
> Sent: Wed, January 03, 2001 12:50 PM
> To: Mevorach, Assaf
> Cc: 'erez@savan.com'; ILUG
> Subject: RE: making a static binary out a dynamic
>
>
>
> 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 really _try_ this, or you're only guessing? when the
> linker links
> a library to an executable, 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.
you are right, my mistake,
>
> > 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.
here you are not right, the linker add the trasitive closure of the calls
from libc you did, and since it can not
add evry function on its own it adds the entire object file it came from (as
you know static librarys are just
archive of objects with search key)
so by adding only the needed functions you can 'earn' alot of size
>
> > 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).
now there is no need to complicate it so much, you can get the sources of
libc very easy, and look there for
your functions, or you can disassemble the libc.a and take it from there as
assembly.
>
> 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
>
>
=================================================================
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