To set up for making a light shared ELF libc, you need a set of
linked binaries which are to link with it.  These are produced by

    ld -r -x -o combined.o a.o b.o c.o d.o

where all .o files included in the real binary appear on the right.
You must not link against any shared libraries, e.g., libext2fs.so,
but you must have static libraries to get a correct set.  Put these
combined.o files in the directory ./old/.

You need a compiled version of the current library.  Setup links to
elfshared/libc and elfshared/libgcc in the current directory.  You
alse need two files, Infiles, containing the minimal libc routines:

	libc/init-misc.o
	libc/set-init.o
	libc/__fpu_control.o
	libc/__setfpucw.o

and mcc-misc.c, which contains dummies for the library routines
you wish to avoid calling in; for example:

	void __yp_check(void){}
	void endnetgrent(void){}
	void getnetgrent(void){}
	void innetgr(void){}
	void setnetgrent(void){}
	void yp_get_default_domain(void){}
	void yp_match(void){}

Compile this last and get a list of the files in ./old/:

	gcc -s -fPIC -c mcc-misc.c
	ls ./old/ >F

It is necessary to have a list of the library files containing
each entry point.  The combine program does this:

	ar cru libc.a libc/*.o
	ar cru libgcc.a libgcc/*.o
	nm libc.a|./combine >libcs
	nm libgcc.a|./combine >libgccs

Copy the files from old/ to new/ to start out, and repeat this loop:

loop:	for i in new/*;do nm $i;done|egrep ' U '|sed -e 's/.*U //'|sort -u >b
	while read i;do egrep " $i\$" libcs libgccs;done <b >c
	vi c

In this edit, remove the routine names and convert the remains into
pathnames for the files; e.g., libc/execl.o.

	cat Infiles c|sort -u >I
	mv I Infiles 
	rm -f libc.a new/*
	ar cru libc.a `cat Infiles `
	for i in `cat F`;do ld -r -x old/$i libc.a mcc-misc.o -o new/$i;done
	goto loop:

Eventually the loop will terminate with no undefined functions except
those in libgcc and/or ld-linux.so, which is usually no more than

	_GLOBAL_OFFSET_TABLE_
	__divdi3

At this point, create a test library and link the programs against it:

	rm -f libc.a new/* libfred.so.1
	gcc -shared -Wl,-soname,libfred.so.1 -o libfred.so.1 \
		`cat Infiles` mcc-misc.o
    for i in `cat F`;do
      /usr/i486-linux/bin/ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 \
	-o new/$i /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o \
	old/$i ./libfred.so.1 /usr/lib/gcc-lib/i486-linux/2.7.2/libgcc.a \
	/usr/lib/crtend.o /usr/lib/crtn.o
    done

If this completes without error, you are probably home free.  But to
test the library, you can do this:

	cp libfred.so.1 /lib
	cd ./new

and then execute the programs.
