Slashdot Mirror


Can you Shrink glibc?

alterity asks: "I want to roll my own root/boot rescue disk. So far so good - I have created a root/boot disk that works with the latest stable kernel and glibc(2.1). I have saved space using busybox and asmutils. But the biggest dead-weight of space is the the size of the glibc library - a touch over one meg. I notice that the Debian distribution has a much reduced glibc library under 400k in size. Does anyone know how they do it and what can be excised from glibc for this purpose?" Shrinking critical libraries is always good thing.

6 comments

  1. Re:Glibc size. by Anonymous Coward · · Score: 0

    Be careful stripping libc, you can break it. I think that 'strip --strip-debug' works and 'strip --strip-unneeded' doesn't, but it's been awhile.

    You can add '-R .comment' to the strip command line to get back another 60k or so. Do this to everything, not just libc (the amount saved varies widely but it always helps).

  2. How debian does it by Anonymous Coward · · Score: 0

    Debian uses some script to check the symbols used by binaries on the boot disks, and then create a libc containing only those symbols. How this black magic is accomplished, I don't really know, but the source for everything is in cvs. Note that the script was broken for glibc 2.1 until just a few days ago.

    1. Re:How debian does it by abamfici · · Score: 1

      To remove the symbols try tooling around with the "strip" command. From the manpage:

      DESCRIPTION
      GNU strip discards all symbols from the object files objfile. The list of object files may include archives. At least one object file must be given.

      ~Kevin
      :)

    2. Re:How debian does it by dsplat · · Score: 1

      Checking for the symbols is easy enough. nm will give you that. It seems that I have to make use of it every time we upgrade a third party tool here at work, because some folks are constantly renaming libraries and moving things around.

      How to remove the ones you don't want might be a bit tougher. One possiblity would be to do it by hand, going through glibc looking at the contents of the files and removing what you don't need, for a trimmed down version.

      --
      The net will not be what we demand, but what we make it. Build it well.
  3. Re:Glibc size. by Anonymous Coward · · Score: 0

    I have run stripped libc for a long time w/o problem. Then again, maybe it was libc5.

  4. Glibc size. by Inoshiro · · Score: 1

    Well, this may seem obvious, but someone has to say it. Is it stripped, or is it full of debug info? :-)

    Otherwise, nary a clue, I use Slackware (libc5 still).

    --
    --
    Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.