Writing a custom libc

L

Levi Campbell

where can I get the pieces needed to write a custom C library? I ask
because I'm working on a rather large set of libraries where the extra
stuff in glibc is a waste of space.
 
I

Ian Collins

Levi said:
where can I get the pieces needed to write a custom C library? I ask
because I'm working on a rather large set of libraries where the extra
stuff in glibc is a waste of space.
Eh? Not including stuff you don't use is the linker's job.
 
E

Eric Sosman

Ian said:
Eh? Not including stuff you don't use is the linker's job.

The linker isn't always up to the task. For example,
a program that never uses any of the <locale.h> functions
but uses <ctype.h> might drag in a whole bunch of the locale
machinery, because the <ctype.h> facilities are sensitive to
the locale changes the program will never perform. Also, the
use of shared libraries tends to make library inclusion an
all-or-nothing proposition -- although in this case, the amount
of space used in the entire system usually decreases even if
the amount "used" by a single program seems to be greater than
if it incorporated only the "necessary" functions.

If the O.P. has actually measured the amount of "extra
stuff" and found that it can't be tolerated (highly unlikely;
if he'd measured anything he'd probably have mentioned it),
there are a couple of possible strategies. First, he could
see whether his system supports "static linking," following the
model implicit in Ian Collins' post. If that's not enough, he
can get hold of the glibc source and start throwing things out
until he's got a smaller (maybe), less functional (surely), and
non-conforming (probably) library that works for his program
but for few others. And I bet it won't save him much, either.
 
L

Levi Campbell

Eric said:
The linker isn't always up to the task. For example,
a program that never uses any of the <locale.h> functions
but uses <ctype.h> might drag in a whole bunch of the locale
machinery, because the <ctype.h> facilities are sensitive to
the locale changes the program will never perform. Also, the
use of shared libraries tends to make library inclusion an
all-or-nothing proposition -- although in this case, the amount
of space used in the entire system usually decreases even if
the amount "used" by a single program seems to be greater than
if it incorporated only the "necessary" functions.

If the O.P. has actually measured the amount of "extra
stuff" and found that it can't be tolerated (highly unlikely;
if he'd measured anything he'd probably have mentioned it),
there are a couple of possible strategies. First, he could
see whether his system supports "static linking," following the
model implicit in Ian Collins' post. If that's not enough, he
can get hold of the glibc source and start throwing things out
until he's got a smaller (maybe), less functional (surely), and
non-conforming (probably) library that works for his program
but for few others. And I bet it won't save him much, either.

You *do* realize you've given me the answer don't you? All I have to do
is write a new locale that can handle braille and patch the aclocal.m4
and Makefile to a) skip the threading and use sockets. b) use the
braille-enabled locale as the default.

thanks!
 
I

Ico

Levi Campbell said:
where can I get the pieces needed to write a custom C library? I ask
because I'm working on a rather large set of libraries where the extra
stuff in glibc is a waste of space.

Assuming you are running linux: other C libraries with a much smaller
footprint exist, take a look at uClibc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,520
Latest member
KrisMacono

Latest Threads

Top