Jump to Navigation

Ld.so

Introduction

This is the second step in installing glibc-2. Before we install anything for glibc-2, we first update the dynamic linker. This is the program that admistrates all shared libraries and loads them when needed. Glibc uses its own dynamic linker, but the old dynamic linker must cooperate with it. Only versions newer than 1.9.0 do that.

Preparing for compilation

Even though this is a relative step-by-step guide, it would be wise to read the most important documentation yourself; especially the README file. The newest public version as of the writing of this document is ld.so-1.9.9. Installation of newer versions may differ slightly.

Installing the dynamic linker is potentially dangerous. If something would go really wrong (fortunately, that is not very likely), you could be left with a system that can not run anything. It is sensible to check you have a set of rescue disks somewhere that you can use to boot the system with if everything else fails.

Patches

You should apply both patches; they are needed if you want to follow this step-by-step guide.

  • Disable test programs
    This patch disables the making of some test programs. They are not important anyway, and seem not to work properly.
  • Set correct compiler path
    Forces a correct call of the libc5-compiler.

You can apply this patch by entering the ld.so directory and using the following command:

patch -p1 -E < filename

Compiling and installing ld.so

I will assume you use bash as shell; if not, some commands may slightly differ. I will explain each step.

make clean

ld.so comes with pre-compiled binaries; this throws them away, so we can compile them ourselves.

make AOUT_SUPPORT=false

This recreates all binaries. I assume here you have no old libc-4 a.out binaries lying around; if you have, you must change false to true.

./instldso.sh --force --devfiles

This installs the dynamic linker. Remember you must be root to do this. The --force argument is there to force you to read the README file. Please do read it before installing! The --devfiles argument is needed because libc-5 is our main C-library. If you want to know what will be installed, you can add env PREFIX=/tmp at the very beginning of the command line to install the dynamic linker at a temporary location. Do not forget to do a proper installation afterwards!

Checking the installation

Try running ldconfig -p. You should get a long list of installed libraries on your system:

94 libs found in cache `/etc/ld.so.cache' (version 1.7.0)
libz.so.1.0.4 (ELF) => /usr/lib/libz.so.1.0.4
libz.so (ELF) => /usr/lib/libz.so
[....]
ld-linux.so.1 (ELF) => /lib/ld-linux.so.1

ldd -v should report the same version as the dynamic linker:

(bash) ldd -v
ldd: version 1.9.9

Finally, you should be able to run commands like /bin/ps (specify the path explicitly to disable shell builtins).

You can find a manifest of all installed files below.

What to do if everything fails

If something went hideously wrong, you probably can't run any programs anymore. Do not log out! Fortunately, in almost every distribution there is a program sln that is statically linked and creates symbolic links. Even if ls does not work anymore, you can still use echo *. Go to /lib and look for a file ld-linux.so.1.?.?. Now try this command:

 sln ld-linux.so.1.?.? ld-linux.so.1

Substitute the version you found for the question marks. With a little luck, everything should work again. If this does not help, you will have to use a rescue disk to boot with and correct the problem...



Historic_content | by Dr. Radut