If you don't already have GCC installed, it's probably best to do a normal GCC compilation and installation before messing about. When you have done this do

unix$ make clean
in the gcc compilation directory to make sure there are no hang-overs.

If you have GCC around already, you need to either find the directory where it was built or unpack the distribution to get a build directory.

Configure GCC by typing ./configure then compile with

unix$ make CC=gcc CFLAGS='-fPIC -O2' libgcc.a
This will build far more than you need, but it's more trouble than it's worth to fiddle about to build just what you want.

You now have all the code you need compiled, all that remains is to assemble it into a shared library, the gcc makefile doesn't know how to do this.

We do it by unpacking the normal, unshared library into a temporary directory and linking the bits together as follows:

unix$ mkdir tmpdir unix$ cd tmpdir unix$ ar x ../libgcc.a unix$ cd .. unix$ gcc -shared -fno-shared-data -o tmpdir/*.o